Filter array using grep method in jquery
We know that filtering arrays in js native is achieved by the filter method, so what method is used to achieve it in jquery? jQuery has already prepared a useful method for us: grep(), which immediately implements a small demo. (remove the 3rd element)
JavaScript
$(function(){
var arr = ['jeevin','amin','preo','lilei','hameimei'];
var arrAfer = $.grep(arr,function(n,i){
return i != 2;
});// console.log(arrAfer);
$.each(arrAfer,function(index,item){
console.log(item);
});})
0 Comments