DEV Community

Cover image for JavaScript Array Methods
hebaShakeel
hebaShakeel

Posted on

JavaScript Array Methods

concat( ) - Merges two or more arrays into one new array.

copyWithin( ) - Copies array elements within the array, to and from specified positions.

indexOf( ) - Returns the first index at which the given element is found.

lastIndexOf( ) - Gives the last index from the end of the array.

includes( ) - Checks if the array contains the specified element

join( ) - Concatenates all the elements of an array into a new string and returns the string.

entries( ) - Returns a key/value pair array iteration object

every( ) - Executes a given function on every item of an array and returns true only if the callback function returns true for every element of the array.

fill( ) - Changes all the elements in an array with a provided static value.

filter( ) - Creates a new array with every element in an array that passes a test.

find( ) - Returns the value of the first element in an array that passes a test.

flat( ) - Creates a new array with all the sub arrays elements concatenated into it.

forEach( ) - Executes a given function on every element in an array.

from( ) - Creates an array from an object.

pop( ) - Removes the last element of an array.

push( ) - Adds a new element at the end.

shift( ) - Removes the first element in the array.

unshift( ) - Adds a new element to the beginning.

slice( ) - Returns a shallow copy of a portion of an array into a new array object.

splice( ) - Removes or replaces elements in an array in a specified way and position.

sort( ) - Sorts the elements of an array by manipulating the array.

reverse( ) - Reverses an array, as suggested by its name.

reduce( ) - Executes a callback function on every element of an array and returns a single output value.

reduceRight( ) - Reduces the values of an array to a single value (right-to-left).

map( ) - Executes a given function on every element of the array and returns a new array.

I hope you found this list of array methods helpful. Don’t forget to post your queries, doubts in the comment section below. I will be more than glad to help!

Thank You!

Top comments (0)