Object-has-property
Determine if an Object has required property or properties
Information
Object-has-property
NPM Package: Description: Determine if an Object passed in first argument has required property passed in second argument. There is possibility to pass an Array of properties in second argument to check for multiple properties.
False
if first argument is not an Object
Returns False
if second argument is not an Array nor String
Returns False
if type of any properties is Undefined
Returns True
if property is found in Object.prototype
Returns Usage
Install
$ npm install --save object-has-property
Examples
var has = ; var a = foo: 'bar'; console;
true
Outputs var has = ; var a = foo: 'bar'; var required = 'foo' 'missing'; console;
false
because property missing
is not found
Outputs var has = ; var a = foo: 'bar' notmissing: 'wohoo'; var required = 'foo' 'notmissing'; console;
true
Outputs var has = ; var a = foo: 'bar' notmissing: undefined; var required = 'foo' 'notmissing'; console;
false
because notmissing
is undefined
Outputs var has = ; console;