DEV Community

Pratik Lochawala
Pratik Lochawala

Posted on

Javascript most useful array functions

push

push method adds one or more element at the end of an array

push

pop

pop is removed the last element of the array & return that element

pop

shift

A shift method removes the first element from the array and all other element indexes decrease by 1

shift

unshift

unshift method adds a new element at the beginning of an array and all other element indexes increase by 1

unshift

concat

concat method concat two or more array and return a new array

concat

reverse

reverse method reverses and returns the array

reverse

slice

A slice method return portion of an array as a new array without touching the existing array it's accepted 2 optional arguments start index & end index

slice

splice

splice method uses to add or remove an element from an array. It's accepted 3 argument start index, delete count & new elements, it's return deleted elements.

splice

find

find method return a 1st element that match with given test

find

filter

filter method returns an element that matches with given test

filter

some

*some method returns true or false if one of the array element is pass in test condition *

some

every

every method checks whether all elements in an array pass the applied test and return true if pass else false

every

map

map method creates a new array with result to apply given function to each element

map

sort

sort method short array in alphabetical order. it's sort array values as strings

sort

More sorting example

reduce

reduce method reduces the array to a single value from left to right

reduce

Wrapping up!

Share this blog with your friends πŸ‘©πŸΌβ€πŸ€β€πŸ§‘πŸΌ and developers πŸ‘¨β€πŸ’» you know and let them know these

Your feedback and comments are very important to me. πŸ’Œ

Get in touch πŸ€œπŸ€›

Instagram

Top comments (0)