Skip to content

Instantly share code, notes, and snippets.

@dmiro
Last active August 8, 2017 19:53
Show Gist options
  • Save dmiro/5584375 to your computer and use it in GitHub Desktop.
Save dmiro/5584375 to your computer and use it in GitHub Desktop.
hasOwnProperty correct use
var foo = {
hasOwnProperty: function() {
return false;
},
bar: 'Here be dragons'
};
foo.hasOwnProperty('bar'); // siempre devolverá false
// Utilice otro objeto con hasOwnProperty y llamelo con 'this' para asignarlo a foo
({}).hasOwnProperty.call(foo, 'bar'); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment