According to the $.grep() documentation I would think that the code below would print 2. But instead it’s printing 0,1,2. See this fiddle. Am I going loco?
var arr = [0, 1, 2];
$.grep( arr, function(n,i) {
return n > 1;
});
$('body').html( arr.join() );
$.grepreturns a new array – it doesn’t modify your existing one.You want
Check out the $.grep docs for more information