FilterableExamplesFree
map()Creates new array with results of calling fn on every elementTransform
[1,2,3].map(x => x * 2) // [2,4,6]
filter()Creates new array with elements that pass the testTransform
[1,2,3,4].filter(x => x > 2) // [3,4]
reduce()Reduces array to a single value by accumulatingTransform
[1,2,3].reduce((a,b) => a+b, 0) // 6
forEach()Executes fn once for each element. Returns undefinedIterate
[1,2].forEach(x => console.log(x))
find()Returns first element that passes testSearch
[1,2,3].find(x => x > 1) // 2
findIndex()Returns index of first element that passes testSearch
[1,2,3].findIndex(x => x > 1) // 1
some()Tests if at least one element passesSearch
[1,2,3].some(x => x > 2) // true
every()Tests if all elements passSearch
[1,2,3].every(x => x > 0) // true
includes()Checks if array contains a valueSearch
[1,2,3].includes(2) // true
indexOf()Returns first index of value, or -1Search
[1,2,3].indexOf(2) // 1
push()Adds elements to end. Returns new lengthMutate
arr.push(4) // arr is now [..., 4]
pop()Removes last element. Returns itMutate
[1,2,3].pop() // 3
shift()Removes first element. Returns itMutate
[1,2,3].shift() // 1
unshift()Adds elements to start. Returns new lengthMutate
arr.unshift(0) // [0, ...]
splice()Adds/removes elements at indexMutate
arr.splice(1, 1) // remove 1 at index 1
slice()Returns shallow copy of portionTransform
[1,2,3,4].slice(1,3) // [2,3]
concat()Merges two or more arraysTransform
[1,2].concat([3,4]) // [1,2,3,4]
flat()Flattens nested arrays by depthTransform
[[1,2],[3]].flat() // [1,2,3]
flatMap()Maps then flattens by one levelTransform
[1,2].flatMap(x => [x, x*2]) // [1,2,2,4]
sort()Sorts elements in placeMutate
[3,1,2].sort() // [1,2,3]
reverse()Reverses array in placeMutate
[1,2,3].reverse() // [3,2,1]
join()Joins all elements into a stringTransform
[1,2,3].join("-") // "1-2-3"
Array.from()Creates array from iterable or array-likeCreate
Array.from("abc") // ["a","b","c"]
Array.isArray()Checks if value is an arraySearch
Array.isArray([1]) // true
at()Returns element at index (supports negative)Search
[1,2,3].at(-1) // 3
Share:

Love this tool? Explore 999+ more

Free online tools for images, PDFs, text, code, and more. All running in your browser.

Explore All Tools