JavaScript Array Methods Flashcards
length
gives the length of an array
pop( )
removes the last element
push(el)
add an element to the end
shift( )
Remove an element from the beginning
unshift(el)
adds an element to the beginning
join(“”)
Creates a string out of an array
toString()
Creates a string out of an array
.concat([])
Creates one array out of two
slice(begin, end, step)
Returns the sliced part but does NOT mutate the original array.
splice(start, amount, element, …)
mutates the original array by adding or removing elements.
sort((a, b) => a - b)
sorts an array in ascending or descending order.
delete arr[idx]
removes an element from an array.
.indexOf(element, start )
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.
.find(element )
returns the first element that satisfies the provided testing function otherwise returns undefined.
includes( )
determines whether an array includes a certain value among its entries, returning true or false as appropriate.