A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/Array/push below:

push · WebPlatform Docs

push Summary

Appends new elements to an array, and returns the new length of the array.

Syntax
push([ item1  [ item2 [. . . [ itemN ]]]])
item, item2,. . ., itemN
Optional. New elements of the Array.
Examples

The following example illustrates the use of the push method.

var number;
 var my_array = new Array();

 my_array.push (5, 6, 7);
 my_array.push (8, 9);

 number = my_array.pop();
 while (number != undefined)
    {
    document.write (number + " ");
    number = my_array.pop();
    }

 
 
Remarks

The push and pop methods allow you to simulate a last in, first out stack.

The push method appends elements in the order in which they appear. If one of the arguments is an array, it is added as a single element. Use the concat method to join the elements from two or more arrays.

See also Specification

[15.4.4.7 Array.prototype.push ( [ item1 [ , item2 , … ] ] )] ECMAScript® Language Specification Standard ECMA-262 5.1 Edition / June 2011

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4