Given
var stuffs = [
{ id : 1, name : "orange"},
{ id : 2, name : "apple"},
{ id : 0, name:"grapes"}
];
var filterMethod1 = new function(o){return (o.id>=1);}; // this gives undefined error for o
function filterMethod2(o) {return (o.id>=1);};
Why is using anonymous function not working for array filter() method?
var temp = stuffs.filter(new function(o){ return (o.id>=1);}); // o is undefined if used this way
Using declared function works fine:
var temp = stuffs.filter(filterMethod2);