JavaScript Array Methods Flashcards

1
Q

length

A

gives the length of an array

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

pop( )

A

removes the last element

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

push(el)

A

add an element to the end

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

shift( )

A

Remove an element from the beginning

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

unshift(el)

A

adds an element to the beginning

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

join(“”)

A

Creates a string out of an array

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

toString()

A

Creates a string out of an array

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

.concat([])

A

Creates one array out of two

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

slice(begin, end, step)

A

Returns the sliced part but does NOT mutate the original array.

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

splice(start, amount, element, …)

A

mutates the original array by adding or removing elements.

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

sort((a, b) => a - b)

A

sorts an array in ascending or descending order.

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

delete arr[idx]

A

removes an element from an array.

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

.indexOf(element, start )

A

finds the index of the first element matching the one given to the method. start is optional and determines where should the search begin. Returns -1 if it doesn’t find the element.

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

.find(element )

A

returns the first element that satisfies the provided testing function otherwise returns undefined.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
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
16
Q

.at( integer )

A

takes an integer and return the item at that index, allowing for positive and negative integers.

17
Q

.entries( )

A

returns an array that contains key/value pairs for each index in the array

18
Q

.every(function, hisArg:optional)

A

checks if all the elements in the array pass the test. Returns a Boolean. if all pass the test returns true.

19
Q

.some(function, hisArg:optional)

A

Checks if one element in the array passes the test. If one passes then returns true. Otherwise, returns false.

20
Q

.filter(function, thisArg:optional)

A

creates a shallow copy of the elements in the array that pass the test.

21
Q

findIndex(function, thisArg: Optional)

A

Returns the first index of element in an array that satisfies the testing function, returns -1 if nothing passes the test.

22
Q

flat(depth:optional)

A

Creates a new array with all subarrays concatenated.

23
Q

flatMap(function, thisArg:optional)

A

Returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level.

24
Q

forEach(function, thisArg: optional)

A

Runs a function for each element in the array.

25
Q

Array.from()

A

creates a new, shallow copy instance from an iterable or array-like object.

26
Q

.keys()

A

returns an array iterator object that contains the keys for each index.

27
Q

map(function, thisArg: optional)

A

creates a new array populated with the results of calling a provided function on every element in the calling array.

28
Q

.reduce((acc, curr, idx)

A

instances executes a user-supplied “reducer” callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.

29
Q

reverse()

A

reverses the whole array

30
Q
A