Nemo's Parental Misguidance
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

has-own-prop

1.0.1 • Public • Published

has-own-prop Build Status

A safer .hasOwnProperty()

Shortcut for Object.prototype.hasOwnProperty.call(obj, prop).

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 --save has-own-prop

Usage

const hasOwnProp = require('has-own-prop');
 
const obj = Object.create(null);
obj.unicorn = true;
 
obj.hasOwnProperty('unicorn');
//=> 'TypeError: undefined is not a function'
 
hasOwnProp(obj, 'unicorn');
//=> true

License

MIT © Sindre Sorhus

install

npm i has-own-prop

Downloadsweekly downloads

470

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar