Issue on using Object.prototype and jQuery
I was just wondering...kidding, I'm actually facing the problem.
I created the following method:
Object.prototype.keys = function(filter_fn) {
// gets all keys and filter them using filter_fn function (if
defined)
var e, r = [];
filter_fn = filter_fn ? filter_fn : function() { return
true; };
alert(123);
for(e in this) {
if(!(e in Object.prototype)) filter_fn.call(false,
this, e) && (r[r.length] = e);
}
return r;
};
But jQuery executes it without my permission when I call:
$(function () {...});
Big problem, huh?
Why don't jQuery verifies if each element of a given Object instance
is an Object prototype method or not (like I did in the above code)?
So it would traverse only for the real Object instance itens, wouldn't
it?
Because my guess is that jQuery calls my fresh new Object prototype
methods...
How to solve this?
To edit *ALL* "for in" loops in jQuery?
Or am I very wrong about this my theory?