Pearl Apps Blog
Jan 16, 2022

Lists of Top 10 JavaScript array methods a beginner Js developer should know

1. Push

arr.push(..element) adds a new element to the end of an array and returns the new length of the array. arr.push() method mutates the original array.

arrName.push(element1,element2,…)

The call arr.push(...) is equal to arr[arr.length] = ...

2. Pop

arr.pop() method removes an element from the end of an array and returns the removed array. This method also changes the original array and it’s length.

arrayName.pop()

3. Shift

arr.shift() method removes the first element from an array and and returns the extracted element. This method is also changes the length of the original array.

arrName.shift()

4. Unshift

arr.unshift(elements) method adds one or more element at the beginning of an array and returns the new length of the array.

arrName.unshift(item1, item2,….)

5. Splice

arr.splice() method change the original array by inserting, removing, and replacing elements.

//Syntex array.splice(start[,deleteCount[, item1[, item2[, ...]]]])

Starting from the index

0

it removed

1

element.

remove and replace

6. Slice

arr.slice() method selects a portion of an array and returns a new array copying to it all items from index start to end. The original array does not change.

returns a shallow copy of a portion of an array.

7. Includes

 method looks for item starting from index given and returns true if found otherwise returns false.

return value: true/false.

8. forEach (Iterate)

9. Join

 method creates a string of array items by concatenating all the elements of an array. They are separated by commas or any other given separator (/, — , +, ).

return value: string.

10. toString

toString() method converts an array to a string and returns string as a result.

return a string value.

Pearl App

Pearl App

Pearl Apps Terms and conditions / Privacy Policy

Leave a Reply

Related Posts

Categories