Created
September 14, 2018 13:38
-
-
Save quisido/48d0f853057bd3db99b470431c5e1f1c to your computer and use it in GitHub Desktop.
Object.prototype.hasOwnProperty.call
This file contains hidden or 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
const myObject = Object.create(null); | |
myObject; // {} | |
myObject.test; // undefined | |
Object.prototype.hasOwnProperty.call(myObject, 'test'); // false | |
// Uncaught TypeError: | |
// myObject.hasOwnProperty is not a function | |
myObject.hasOwnProperty('test'); | |
myObject.test = true; | |
myObject; // { test: true } | |
myObject.test; // true | |
Object.prototype.hasOwnProperty.call(myObject, 'test'); // true | |
// Uncaught TypeError: | |
// myObject.hasOwnProperty is not a function | |
myObject.hasOwnProperty('test'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment