Sorry man, I'm still not understanding the message you are trying to convey. Is it that when looping through object literals that don't inherit from other objects, it's not necessary to include the hasOwnProperty check?
var prop;
var A = {
foo: 'bar',
fooFn: function () {}
};
var B = Object.create(a);
/**
* ensures that you are only looping through
* properties that belong only to B. Will not
* execute code on properties from A.
*/
for (prop in B) {
if (b.hasOwnProperty(prop)) {
console.log(b[prop]);
}
}
/**
* will execute code on not only properties on B
* but it will also loop through properties on A.
*/
for (prop in B) {
console.log(b[prop]);
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sorry man, I'm still not understanding the message you are trying to convey. Is it that when looping through object literals that don't inherit from other objects, it's not necessary to include the
hasOwnProperty
check?