Javascript Array object splice () method, arraysplice

Source: Internet
Author: User

Javascript Array object splice () method, arraysplice

The splice () method adds or removes a project from an array, and returns the deleted project. This method will change the original array.

Syntax:

ArrayObject. splice (index, howmany, item1,..., itemX)
Index is required. Integer that specifies the position of the added/deleted project. A negative number can be specified from the end of the array.
Howmany is required. The number of projects to delete. If it is set to 0, the project will not be deleted.
Item1,..., itemX (optional. Add a new project to the array.
The splice () method returns the Array containing the new Array of the deleted project, if any.
The splice () method deletes zero or multiple elements starting from the index and replaces the deleted elements with one or more values declared in the parameter list.
If an element is deleted from an arrayObject, an array containing the deleted element is returned.
The splice () method and slice () method have different functions. The splice () method directly modifies the array.


Example:

Output:
George, John, Thomas, James, Adrew, Martin
George, John, William, Thomas, James, Adrew, Martin
George, John, Billiam, Thomas, James, Adrew, Martin
George, John, Milliam, Adrew, Martin

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.