I was wondering about the differences between Grep and Filter :
Filter :
Reduce the set of matched elements to those that match the selector or pass the function's test.
Grep :
Finds the elements of an array which satisfy a filter function. The original array is not affected.
ok.
so if I do this in GREP :
var arr = [ 1, 9, 3, 8, 6, 1, 5, 9, 4, 7, 3, 8, 6, 9, 1 ];
myNewArray= jQuery.grep(arr, function(n, i){
return (n != 5 && i > 4);
});
I could do also :
var arr = [ 1, 9, 3, 8, 6, 1, 5, 9, 4, 7, 3, 8, 6, 9, 1 ];
myNewArray= $(arr).filter( function(n, i){
return (n != 5 && i > 4);
});
In both situations I still can access to the original array...
so...where is the difference ?