Array in JavaScript – push() Method

Array in JavaScript push() Method appends the given element or elements in the last of array. It returns the length of the new array.

Syntax is as below:

item1, item2, …..itemN: Items to add at the end of array

Return Value:

push() method returns the length of the new array.

Example:

Output: This will give the following output:

Try push() method yourself.

Tip: To add items at the beginning of an array, use the unshift() method.

You Might Interested In

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.