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!