push() Array Method in JavaScript

When you want to add something to an array, just push() it in:

var lyrics = ['push', 'it', 'real'];

lyrics.push('good');

// [ 'push', 'it', 'real', 'good' ]

The syntax is real simple:

myArray.push(toAdd);

You can also push multiple items at once:

myArray.push(item1, item2, item3);
  Tweet It
✖ Clear

🕵 Search Results

🔎 Searching...