DEV Community

Vishnu Priya S
Vishnu Priya S

Posted on

Basic Array methods.

toString() -- elements in a single value with the help of comma separated string.

at() -- returns an indexed element from an array, returns the same as []

length() -- set the length size and return the length.

join() -- works like toString you can specify the separator (symbols)

push() -- adds new element at the end

pop() -- removes the last element from the array.

shift() -- removes the 1st element and all other elements goes in the lower index.

unshift() -- adding the values in the 1st.

delete() -- leaves and provides as undefined.

concat() -- creates a new array by merging the exisiting array.

flat() -- acts as an multiple array make them into single array.

slice()-- create new array , doesn't remove any elements from the src array.

splice() -- add new items to an array

for...of() -- The for...of statements hands you the array values.

forEach()-- calls a function (a callback function) for each array element.

map() -- Note that the function takes 3 arguments:

-> The item value
-> The item index
-> The array itself
When a callback function uses only the value parameter, the index and array parameters can be omitted

filter() -- it checks the condition is true or false , if you return values it never gonna execute.

spread()-- (...) operator expands an array into individual elements.

rest() -- collect the leftovers(...rest)

Top comments (0)