0

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,
1

1 Answer 1

0
Object.defineProperty(Object.prototype, "stuff", {
    enumerable: false,
    value: function(){
        //...
    }
}); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.