Javascript:Add an Element at the End of an Array

by Mohan 2012-09-20 22:17:06

Add an Element at the End of an Array
This tip allows you to add an element at the end of an array using the length property, because the length property is going to be one number higher than the position of the last element in the array. This way acts the same as “push” method. For example:
var myArray = [];
myArray[myArray.length] = 'New Element';
819
like
0
dislike
0
mail
flag

You must LOGIN to add comments