Description
The push() method adds new elements to the end of an array, and returns the new length.
This method has the form:
Array.push(e1,e2,...,eX)
Parameter | Description |
---|---|
e1,e2,...,eX | (required) The element(s) to add to the end of the array |
Examples
The following example shows the basic use of this method.
<script>
var cols = [ "Red", "Green", "Blue" ];
document.write(cols.push("Yellow"));
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|