$. Grep () Filtering Function Array filtering in jQuery

Source: Internet
Author: User
This article mainly introduces the information about $. grep () Filtering Function Array filtering in jQuery. It must be very good and has some reference value. If you need it, you can refer to it.
var = $.grep([1,32,5,63,8,4,-8,-5,2,56,9,62,-6],function (n , i){ if(n>50){ return n; } }); console.log(test);
 
---->[63,56,62]

$. Grep (array, callback, [invert]) contains two parameters: the first parameter is the array to be filtered, the second parameter is the filter condition, and the third parameter (optional) to retain the element (true) or delete the element (false ).

var = $.grep([1,32,5,63,8,4,-8,-5,2,56,9,62,-6],function (n , i){ if(n>50){ return n; } },true); console.log(test); ---->[63,56,62]
var = $.grep([1,32,5,63,8,4,-8,-5,2,56,9,62,-6],function (n , i){ if(n>50){ return n; } },false); console.log(test); ---->[1,32, 5,8,4,-8,-5,2,9,-6]

The above is a small series of jQuery $. grep () Filtering Function Array filtering, hope to help you, if you have any questions, please leave a message, xiaobian will reply to you in a timely manner. I would like to thank you for your support for PHP chinnet!

For more information about $. grep () Filtering Function Array filtering in jQuery, see PHP!

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.