Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-has-property

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-has-property

Determine if an Object has required property/properties

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 04 Feb 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc