DEV Community

Darshan Kumar
Darshan Kumar

Posted on

Methods of Array in Javascript

Image description

push(): Adds one or more elements to the end of an array and returns the new length.
pop(): Removes the last element from an array and returns that element.
shift(): Removes the first element from 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.
concat(): Returns a new array that combines two or more arrays.
slice(): Returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included).
splice(): Changes the contents of an array by removing or replacing existing elements and/or adding new elements
filter(): Creates a new array with all elements that pass the test implemented by the provided function.
join() : The join() method joins all elements of an array into a string.

Top comments (0)