Splice functions in JavaScript

Source: Internet
Author: User

The splice function method in JavaScript is to remove one or more elements from an array, and if necessary, insert a new element at the position of the removed element and return the removed element.

  arrayObj.splice( start, deleteCount, [item1[, item2[, . . . [,itemN]]]])

Where Arrayobj must be selected. An Array object.

Start is a required option. Specifies that the starting position of the element is removed from the array, which is calculated starting at 0.

DeleteCount is a required option. The number of elements to remove.

Item1, item2,.. ., Itemn is a must option. The new element to insert at the location of the removed element.

The splice function method in JavaScript can modify arrayobj by removing the specified number of elements from the start position and inserting new elements. The return value is a new Array object that consists of the removed element.

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.