jquery deletes an array element and an array object method based on the value of the element

Source: Internet
Author: User
Tags array sort

In the premise does not know B in this array subscript, delete b this element
var arrlist = [' A ', ' B ', ' C ', ' d ']; Arrlist.splice (Jquery.inarray (' B ', arrlist), 1);
alert (arrlist);
where Jquery.inarray (' B ', arrlist) is the position of this element in the array arrlist the first parameter in the splice (index,1) function is the position of the element to be deleted in the array, and the second parameter is the number to be deleted.
The array object's methods are: Concat () joins two or more arrays and returns the result. Join () Places all elements of an array into a string. element is delimited by the specified delimiter. Pop () deletes and returns the last element of the array. Push () adds one or more elements to the end of the array and returns the new length. Reverse () Reverses the order of the elements in the array. Shift () deletes and returns the first element of the array slice () returns the selected element from an existing array sort () The elements of the array are sorted splice () deletes the element and adds a new element to the array. Tosource () returns the source code of the object. ToString () converts the array to a string and returns the result. toLocaleString () converts the array to a local array and returns the result. Unshift () adds one or more elements to the beginning of the array and returns the new length. ValueOf () returns the original value of the array object.

jquery deletes an array element and an array object method based on the value of the 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.