JavaScript push () method

Source: Internet
Author: User

JavaScript Array Object manipulation (Array object)

The push () method adds one or more elements to the end of the array and returns the new length.

Note: The new element is added at the end of the array.

Note: This method changes the length of the array.

tip: to add elements at the beginning of an array, use the Unshift () method. This method changes the length of the array!!!

The Pop () method deletes the last element of the array and returns the deleted element. This method changes the length of the array!!!

To remove the first element of an array, use the Shift () method. This method changes the length of the array!!!

Syntax: array. Push (item1, item2, ..., ItemX)

eg

var fruits = ["Banana", "Orange", "Apple", "Mango"];
Fruits.push ("Kiwi", "Lemon", "Pineapple");

Output:

Banana,orange,apple,mango,kiwi,lemon,pineapple

JavaScript push () method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.