Methods Flashcards

1
Q

.concat()

A

Joins two or more arrays. Format array1.concat(array2, array3).

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

constructor

A

returns information on the constructor used to make the array/object/function/whatever.

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

.copyWithin()

A

Copies the first two array elements to the last two array elements. Deletes the original last two elements. Doesn’t work with IE 11

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

.entries()

A

Breaks an array into a series of key/value pairs. Among other things, used when converting data to objects.

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

every()

A

checks if every value in an array passes a test. Used for quality control, defensive programming, and more.

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

fill()

A

Fills an array with a static variable (Static variables can only be changed by the function they appear in, so they hold their value between functions AND don’t take a global scope).

You can specify where variables start getting filled in with the following syntax- fill(variable, start, end).

If no start or end is specified, the whole array is filled in.

Warning: This will over write the original array.

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

.filter()

A

Returns a new array with the filtered elements. Takes a function

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

.find()

A

Finds and returns the first element of an array that passes a test (provided as a function). Does this by iterating over every element in the array. Stops when it finds the first value that passes. If no itempass the test, returns undefined.

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

.findIndex()

A

Finds and returns the index of the first element that passes a test, (provided as a function). Stops when it finds the first value that passes. If no items pass the test, returns -1.

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

.forEach()

A

Calls a function on each element of an array. Does not return a new array.

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

.map()

A

Calls a function on each element of an array, then returns a new array.

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

.from()

A

creates an array from a string.

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

.includes()

A

Checks an Array for a specific value. If the value is found, returns true, otherwise returns false. Note: Its case sensitive.

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

.indexOf()

A

returns the index of the array element. If no element is found, returns -1.

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

.isArray()

A

Returns true if the object is an array.

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

.join()

A

returns an array as a string. Does not change the original array.

17
Q

.keys()

A

Returns the keys (indexes) of an array, as an iteration object.

18
Q

.valueOf()

A

Returns the value of the array. The ‘default’ method of the array.

19
Q

.length

A

Returns the length of the array.

20
Q

.lastIndexof()

A

The same as .indexOf() but starts from the end of the array, to hopefully find the last occurrence of an item in an array.

21
Q

.pop()

A

removes the last element of an array and returns that element.

22
Q

prototype

A

The prototype constructor allows you to add new properties and methods to the Array() object.

When constructing a property, ALL arrays will be given the property, and its value, as default.

When constructing a method, ALL arrays will have this method available.

Note: Array.prototype does not refer to a single array, but to the Array() object itself.

Note: Prototype is a global object constructor which is available for all JavaScript objects.