Possible Duplicate:
jQuery each method does not return value
It seems the return statement does not break the loop and return the function. The following code keeps return false....
var __in__ = function(elem, array){
// $.each(array, function(index, item) {
array.forEach(function(index, item) {
if (item == elem)
return true;
});
return false;
};
console.log(__in__(3,[1,2,3]));
function(){ return true; }in both cases -- it returns from the anonymous function, not from the one that called it!jQuery.grep()?$.inArray().