JavaScript Array Method : push()

The push() method is used to append the new elements in an array. The new element is added in the last of the array and returns the length of the new array. The syntax is as follows :
  array.push(element1, element2, ...., element_n);
Example :
<script>
  var myarray = [100, 200, 300, 400, 500];
  document.write("Array : "+ myarray + "<br/>");
  myarray.push(2000);
  document.write("New Array : " + myarray);
</script>
Output :


Next Topic :