Socket
Socket
Sign inDemoInstall

object-has-property

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-has-property

Determine if an Object has required property/properties


Version published
Maintainers
1
0

Weekly downloads

Readme

Source

Object-has-property

npm version

Determine if an Object has required property or properties

Information

NPM Package: Object-has-property
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.
Returns 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

Usage

Install
$ npm install --save object-has-property

Examples

var has = require('object-has-property');

var a = {
  foo: 'bar'
};

console.log(has(a, 'foo'));
Outputs true
var has = require('object-has-property');

var a = {
  foo: 'bar'
};

var required = [
  'foo',
  'missing'
];

console.log(has(a, required));
Outputs false because property missing is not found
var has = require('object-has-property');

var a = {
  foo: 'bar',
  notmissing: 'wohoo'
};

var required = [
  'foo',
  'notmissing'
];

console.log(has(a, required));
Outputs true
var has = require('object-has-property');

var a = {
  foo: 'bar',
  notmissing: undefined
};

var required = [
  'foo',
  'notmissing'
];

console.log(has(a, required));
Outputs false because notmissing is undefined
var has = require('object-has-property');

console.log(has(Object.prototype, 'hasOwnProperty'));
Outputs true

LICENSE MIT

Keywords

FAQs

Last updated on 04 Feb 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc