Methods Flashcards
.concat()
Joins two or more arrays. Format array1.concat(array2, array3).
constructor
returns information on the constructor used to make the array/object/function/whatever.
.copyWithin()
Copies the first two array elements to the last two array elements. Deletes the original last two elements. Doesn’t work with IE 11
.entries()
Breaks an array into a series of key/value pairs. Among other things, used when converting data to objects.
every()
checks if every value in an array passes a test. Used for quality control, defensive programming, and more.
fill()
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.
.filter()
Returns a new array with the filtered elements. Takes a function
.find()
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.
.findIndex()
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.
.forEach()
Calls a function on each element of an array. Does not return a new array.
.map()
Calls a function on each element of an array, then returns a new array.
.from()
creates an array from a string.
.includes()
Checks an Array for a specific value. If the value is found, returns true, otherwise returns false. Note: Its case sensitive.
.indexOf()
returns the index of the array element. If no element is found, returns -1.
.isArray()
Returns true if the object is an array.