arr.forEach(function(val, I, arr)) |
Executes a function for each value. |
arr.every(function(val, i, arr)) |
Returns true if every value passes the function test |
arr.reverse() |
Reverses the original array |
Searching |
arr.includes(val) |
Returns true if array contains a value |
arr.indexOf(val) |
Returns the index of a value in an array or -1 if not found |
arr.find(function) |
Returns the value of the first index to satisfy the function |
arr.findIndex(function) |
Returns the index of the first value to satisfy the function |
Add Values |
arr.splice(start, 0, items...) |
Adds items to array beginning at starting index |
arr.unshift(val) |
Adds val to front of array |
arr.push(val) |
Adds val to back of array |
Delete Values |
arr.splice(start, n) |
Delete n items from array beginning at starting index |
arr.shift() |
Removes arr[0] and returns the value |
arr.pop() |
Removes last value in a array and returns it |
Copy Values |
arr.slice(beg, end) |
Returns a shallow copy of arr from beg to end (non-inclusive) |
To String |
arr.join(separator) |
Returns a string from the array values, with an optional separator string |
JSON.stringify(arr) |
Returns a JSON string representation of array. Deep string. |
arr.toString() |
Returns a comma-delimited string of scalar array values. Shallow string. |
Sorting |
arr.sort() |
Sorts lexicographically |
arr.sort((a, b) => a - b) |
Sorts numbers |
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets