Skip to content

Instantly share code, notes, and snippets.

@quisido
Created September 14, 2018 13:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quisido/48d0f853057bd3db99b470431c5e1f1c to your computer and use it in GitHub Desktop.
Save quisido/48d0f853057bd3db99b470431c5e1f1c to your computer and use it in GitHub Desktop.
Object.prototype.hasOwnProperty.call
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