JavaScript Array Functions
Learn how to use map, filter, reduce, some, every, sort, and splice in JavaScript.
Map
The map() method is used for creating a new array with the same length from an existing one, applying a function to each one of the elements of the first array.
Example
Filter
The filter() method takes each element in an array and it applies a conditional statement against it. If this conditional returns true, the element gets pushed to the output array. If the condition returns false, the element does not get pushed to the output array.
Example
Reduce
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in a single output value.
Example
Sort
The sort() method sorts the elements of an array in place and returns the sorted array.
Example
Some
The some() method tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value.
Example
Every
The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
Example
Splice
The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
Syntax
The index at which to start changing the array.
Get Aliajam’s stories in your inbox
Join Medium for free to get updates from this writer.
deleteCount is an integer indicating the number of elements in the array to remove from start. If 0 will insert new element to the array




