Array.push()

JavaScript 1.2+, Nav4+, NES3+ Syntax

							array.push(arg1,…argN)

Description

The push() method "pushes" the elements specified in the parameter list on to the end of the array in the order they were listed. Table 6.12 shows the arguments and return value associated with this method.

Table 6.12. Arguments and Return Values Associated with push()
Type Item Description
Arguments arg1,…argN One or more elements to be added to the end of the array
Returns The last element added to the end of the array, which is also the last argument in the parameter list

Example

In Listing 6.53, an array of pages is created to represent a stack of papers. The push() method puts two more pages on the end of the array. After the push() method is ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.