7 Must-know Fundamental Array Methods in JavaScript

Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed. Since an array's length can change at any time, and data can be stored at non-contiguous locations in the array,

Reading Time: 2 minutes

Check out the MUST-KNOW array fundamental methods in JavaScript.

1. PUSH

The Array.Push() adds a new element, containing the entered variable, to the end of the array.

2. POP

The Array.Pop() method on the other hand, does quite the opposite, deleting the last element of an array.

3. SHIFT

Shift works almost exactly like POP, with one major difference. It deletes the first value in an array and moves the rest backwards.

4. UNSHIFT

Unshift adds a new value to the start of an array instead of the end (Like the PUSH does)

5. SPLICE

It’s first argument determines where to add new elements.

The Second argument is how many after that point should be deleted.

All other arguments are values you’re adding.

6. SLICE

Slice creates a new Array that contains every element from a certain point on in whatever array you give it!

7. CONCAT

Concat returns a new array with all members of the current one & adds item to it.

Comments