JavaScript Array (Push, Pop, Shift, Unshift)

Array pop(), push(), shift() and unshift() Methods in JavaScript




pop()

Remove an item from the end of an array


pop() returns the removed item.

The method takes no arguments.


push()

Add items to the end of an array


push() returns the new array length.

The value which is an argument passed to the method could be a number, string, object or even array.


shift()

Remove an item from the beginning of an array


shift() returns the removed item.

The method takes no argument.


unshift()

Add items to the beginning of an array


unshift() returns the new array length.

The method takes an argument of value which could be object, array, string, etc.

Comments

Popular posts from this blog

The effects of Artificial Intelligence on complex and tedious tasks

JavaScript Data Types ( String, Number, BigInt, Boolean, Undefine, Null, Object, Symbol)

Reasons, why cloud computing has helped save on space and efficiency