JS Array Cheat Sheet - Dark
JS Array Cheat Sheet - Dark
Basic Methods
Name Return Type Description Results
Concatenate the array passed to
concat Array concat to the end of the array 1 2 3 4 5
Add the elements 4 and 5 to the end of the
[1,2,3].concat([4,5]) array
Array Manipulation
Name Return Type Description Results
push Number
Modifies The Array
Add one or more elements to the
end of the array 1 2 3 4 5
[1,2,3].push(4, 5) Return length of array Add 4 and 5 to the end of the array
pop Element
Modifies The Array
Remove the last element from the
array 1 2 3
[1,2,3].pop() Return removed element Remove the value 3 from the array
shift Element
Modifies The Array
Remove the first element from the
array 1 2 3
[1,2,3].shift() Return removed element Remove the value 1 from the array
unshift Number
Modifies The Array
Add one or more elements to the
start of the array 4 5 1 2 3
[1,2,3].unshift(4, 5) Return length of array Add 4 and 5 to the start of the array
find Element
Select the first element that returns
true to the function passed to find 2
[1,2,3].find(n => n > 1) Get the first element greater than 1
includes Boolean
Return true if the value passed to
includes is in the array false
[1,2,3].includes(4) Check if the value 4 is in the array