Array Methods Flashcards

1
Q

Array.from()

A

creates a new, shallow-copied Array instance from an array-like or iterable object.
> Array.from((string,array),(map func))

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

Array.of()

A

creates a new Array instance from a variable number of arguments, regardless of number or type of the arguments.
> Array.of(7) // [7]
> Array.of(1,2,3) // [1, 2, 3]

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

Array()

A

array constructor, if passed in an integer, creates that many empty spots for the integer, or if a list of integers, creates that array
> Array(7) // creates an array with 7 empty spots of that length
> Array(1, 2, 3) // [1, 2, 3]

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

.concat()

A

Merges two arrays together, doesn’t change the existing arrays, returns new array
> array1 = [ 1, 2, 3], array2 = [4, 5, 6]
> array1.concat(array2) // [1, 2, 3, 4, 5, 6]

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

.every()

A

tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
> .every((function_to_test)) // True or false

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

.fill()

A

changes all elements in an array to a static value

.fill((value),(start),(end))

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

.filter()

A

creates a new array based on if the elements pass the given function

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

.find()

A

returns the value of the first element in the provided array that satisfies the provided testing function.

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

.findIndex()

A

returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns -1.

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

.includes()

A

determines whether an array includes a certain value among its entries, returning true or false as appropriate.

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

.pop()

A

removes the last element from an array and returns that element. This method changes the length of the array.

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

.reverse()

A

reverses an array in place. The first array element becomes the last, and the last array element becomes the first.

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

.shift()

A

removes the first element from an array and returns that removed element. This method changes the length of the array.

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

.some()

A

tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value.
> array.some((func)) // true or false

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

.unshift()

A

adds one or more elements to the beginning of an array and returns the new length of the array.
> array.unshift((element1),(element2)…)

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