Is there a way to add a function to the Object Prototype in a way that it won't be included in a loop for?
Ex:
Object.prototype.stuff = function(){};
var obj = {'hello':1};
for(var i in obj){
console.log(i);
}
//it will log: hello, stuff
//I'd want it to only log hello,
Object.definePropertyand setenumerableasfalse(which is the default): developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… - look at the bottom for browser compatibility. Either that, or usehasOwnPropertywhen iterating with theforloop: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… . Either those, or iterate through the result ofObject.keys(obj): developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…