DEV Community

Vamshi Krishna
Vamshi Krishna

Posted on

Array methods in JavaScript, some of the most commonly used ones include:

.push(): adds one or more elements to the end of an array and returns the new length of the array.
.pop(): removes the last element of an array and returns that element.
.shift(): removes the first element of an array and returns that element.
.unshift(): adds one or more elements to the beginning of an array and returns the new length of the array.
.slice(): returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included) where begin and end represent the index of items in that array.
.splice(): changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
.sort(): sorts the elements of an array in place and returns the array.
.reverse(): reverses the order of the elements in an array in place and returns the array.
.concat(): returns a new array that is the result of concatenating the given arrays or values.
.forEach(): executes a provided function once for each array element.
Many other functions are available in JS like Map, Filter, Reduce, etc.

Top comments (0)