$.grep() filter function array filtering in jQuery
<pre code_snippet_id="1998964" snippet_file_name="blog_20161122_1_1873395" name="code" class="html">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]) has two parameters. The first parameter is the array to be filtered, and the second parameter is the array to be filtered. The first parameter is the filtering condition, and the third parameter (optional) is 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 the $.grep() filter function array filtering in jQuery introduced by the editor. I hope it will be helpful to everyone

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
