You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
3 years ago | |
---|---|---|
.. | ||
index.d.ts | 3 years ago | |
index.js | 3 years ago | |
license | 3 years ago | |
package.json | 3 years ago | |
readme.md | 3 years ago |
readme.md
has-own-prop 
A safer
.hasOwnProperty()
Shortcut for Object.prototype.hasOwnProperty.call(object, property)
.
You shouldn't use .hasOwnProperty()
as it won't exist on objects created with Object.create(null)
or it can have been overridden.
Install
$ npm install has-own-prop
Usage
const hasOwnProp = require('has-own-prop');
const object = Object.create(null);
object.unicorn = true;
object.hasOwnProperty('unicorn');
//=> 'TypeError: undefined is not a function'
hasOwnProp(object, 'unicorn');
//=> true