Singsys blog

How to Append Anything into JavaScript Array

Append in Javascript Array with Push()

The push() method is used for adding one or more elements at the end of an array and returns the new length of the array. In order to add items at beginning of the array unshift() method is used. It  can be used with call() or apply() with objects that are similar to arrays. The push method applies the  length property to identify pint of inserting the given values. When the length property is not  converted into a number 0 is used as index. This considers the possibility of length being nonexistent hence in such scenario length will be created.

(more…)