Array Method 2s Pt Flashcards
from()
Create an array from any iterable object.
includes ()
Checks for specified value in an array, returns a boolean, case sensitive
indexOf()
returns the first index (position) of a specified value.
returns -1 if the value is not found.
starts at a specified index and searches from left to right.
isArray()
returns true if an object is an array, otherwise false
join()
returns an array as a string, does not change the original array.
keys()
returns an Array Iterator (loopable) object with the keys of an array
length
sets or returns the number of elements in an array.
lastIndexOf()
Returns the last index of a specified value
returns -1 if the value is not found.
starts at a specified index and searches from right to left.
map()
calls a function once for each element in an array and create a new array with the results
pop()
removes the last value of the array
changes the original array
returns the removed element
prototype
allows you to add new properties and methods to arrays.
push()
adds an element to the end of the array
reduce()
executes a reducer function for array element. (add & subtract)
returns a single value: the function’s accumulated result.
reduceRight()
executes a reducer function for each array element.
works from right to left.
returns a single value: the function’s accumulated result.
reverse()
reverses the order of the elements in an array.
overwrites the original array.
shift()
removes the first value in an array and assigns it to a variable
slice()
returns selected elements in an array, as a new array.
selects from a given start, up to a (not inclusive) given end
some()
checks if any array elements pass a test (provided as a function)
method executes the function once for each array element
If the function returns true, some() returns true and stops.
If the function returns false, some() returns false and stops.
sort()
sorts the elements of an array in alphabetical and ascending order
overwrites the original array
splice()
adds and/or removes array elements
overwrites the original array.
toString()
returns a string with array values separated by commas
does not change the original array
unshift()
adds an element to the front of an array
valueOf()
returns the array itself, does not change the original array