Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
hasOwnProperty style
var obj = {
foo: 1,
bar: 2
};
Object.prototype.oops = function(){};
// Meh.
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
// ...
}
}
// Better!
for (var key in obj) if (obj.hasOwnProperty(key)) {
// ...
}
@mauricesvay

This comment has been minimized.

Copy link

@mauricesvay mauricesvay commented May 5, 2012

Pretty neat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment