Needlessly Promiscuous, Modularize!
Miss any of our Open RFC calls?Watch the recordings here! »

has-own-property-x

4.1.2 • Public • Published

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

has-own-property-x

Used to determine whether an object has an own property with the specified property key.

module.exports(object, property)boolean

The hasOwnProperty method returns a boolean indicating whether the object has the specified property. Does not attempt to fix known issues in older browsers, but does ES6ify the method.

Kind: Exported function
Returns: boolean - true if the property is set on object, else false.
Throws:

  • TypeError If object is null or undefined.
Param Type Description
object Object The object to test.
property string | Symbol The name or Symbol of the property to test.

Example

import hasOwnProperty from 'has-own-property-x';
 
const o = {
  foo: 'bar',
};
 
console.log(hasOwnProperty(o, 'bar')); // false
console.log(hasOwnProperty(o, 'foo')); // true
hasOwnProperty(undefined, 'foo'); // TypeError: Cannot convert undefined or null to object

Install

npm i has-own-property-x

DownloadsWeekly Downloads

13,432

Version

4.1.2

License

MIT

Unpacked Size

214 kB

Total Files

11

Last publish

Collaborators

  • avatar