Javascript most useful array functions

Javascript most useful array functions

ยท

2 min read

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

Did you find this article valuable?

Support pratik lochawala by becoming a sponsor. Any amount is appreciated!

ย