Skip to main content Accessibility Feedback

Arrays

Array.push()

Add items to an array. Pass the new items in as arguments.

var sandwiches = ['turkey', 'tuna', 'blt'];
sandwiches.push('chicken', 'pb&j');

// logs ['turkey', 'tuna', 'blt', 'chicken', 'pb&j']
console.log(sandwiches);

Works back to at least IE6.