Last active
August 8, 2017 19:53
-
-
Save dmiro/5584375 to your computer and use it in GitHub Desktop.
hasOwnProperty correct use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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