JS Course 1: Fundamental 5 String/Array Methods Flashcards

1
Q

What does filter() do?

A

This method is used to filter through an array only including certain items.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does map() do?

A

This method is used to do something to every single item in an array. Some things you could do to every item is reformat them, add or takeaway something from them, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does sort() do?

A

This method is used to sort an array by a certain designated order. It can also slyly be used to do something to every item in an array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does reduce() do?

A

This method is used to work with every single item in an array, working with a total amount and each item in the array individually.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does reduceRight() do?

A

This method does the same as reduce(), but works from the right of the array to the left.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does Array.from() do?

A

This method returns an array from any iterable object, like a string for instance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does includes() do?

A

This method works on array and returns a boolean value on if the array contains a certain value in it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does some() do?

A

This method checks if at least on thing in your array meets what you’re looking for and returns a boolean value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does every() do?

A

This method checks if all things in your array meet what you’re looking for, very similar to some()’s syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does find() do?

A

This method is similar to filter() but instead of returning a subset of the array you’re working with, it returns JUST the one you are looking for. Specifically, it finds and returns the very first item that meets the criteria you specify.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does findIndex() do?

A

This method is the exact same as find(), but returns the index position of the item that first meets the criteria, which is your parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does findLastIndex() do?

A

Same as findIndex() but works from the back of the array. Aka, right to left.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the […SPREAD] operator do?

A

This operator takes an iterable, like a string or object and allows us to quickly copy all or part of an existing array or objects into another array or object.

You can think of it as being the opposite of a rest parameter, though they look exactly the same!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does push() do?

A

This method adds items to the end of the array. The parameter is what you wish to add to the end of the array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does pop() do?

A

This method extracts the item at the end of the array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does shift() do?

A

This method extracts the item at the beginning of the array.

17
Q

What does unshift() do?

A

This method adds items to the beginning of the array. The parameter is what you wish to add to the beginning of the array.

18
Q

What does splice() do?

A

This method primarily is used to delete items from an array, but can be used in a variety of other ways.

19
Q

What does slice() do?

A

This method is similar to splice() but simpler. It takes two parameters: 1st is where you want to start your slice, and 2nd is where you want to end your slice NOT including the position where the 2nd is.

20
Q

What does concat() do?

A

This method takes an array (before the .) and arguments (inside ()) and concatenates them together left to right. This method can take on (about) infinite arguments to concatenate together.

21
Q

What does Symbol.isConcatSpreadable do?

A

Symbol.isConcatSpreadable can be applied as a property with the value true in an object to make it so if the object is concatenated into a new array, it will allow the values in it to be concatenated, and so the object will not be added as a whole.

22
Q

What does forEach() do?

A

This method allows you to run a function for every element in array. In other words, allows you to iterate through the array doing something to each of it.

23
Q

What does indexOf() do?

A

This method is used to find the index of an item name and returns the index number. If the item cannot be found, it returns -1.

24
Q

What does lastIndexOf() do?

A

Same as indexOf(), but starting from the back of the array. Aka, right to left.

25
Q

What does localeCompare() do?

A

This string method is used on strings so you are able to correctly compare strings.

26
Q

What does reverse() do?

A

This method reverses the order of elements in an array.

27
Q

What does split() do?

A

This method allows you to take a string and split it into several parts based on the parameter in the parentheses. The outcome of this method is a new array with values from the string.

28
Q

What does join() do?

A

This method is very similar to split(), but the other way around. It takes an array and joins all the items together back into a string.

29
Q

What does Array.isArray() do?

A

This method is used to test if an array is an array or not. It returns a boolean value.

30
Q

What is “thisArg” do?

A

This keyword is applicable to many array methods like find(), filter(), and map() where you can insert an optional parameter named thisArg.

It’s rarely used so this section is just good to know.

31
Q

What does flat() do?

A

This method is used to flatten out an array, aka make it so all items are the same depth.

32
Q

What does parseInt() do?

A

This method takes a string (or really even a number) and turns it into a number input. It works similar to the unary plus operator.