property-exists

v1.0.0
Return a boolean indicating whether the object has the specified property (as a direct property of that object)
property object exists check

property-exists

Return a boolean indicating whether the object has the specified property (as a direct property of that object)

Install

$ npm install --save property-exists

Usage

var propertyExists = require('property-exists');

var person = {
  name: 'Ygritte',
  say: function() {
    return "You know nothing, Jon Snow";
  }
};

propertyExists(person, 'name'); // => true
propertyExists(person, 'foobar'); // => false

var anotherPerson = Object.create(person);

propertyExists(anotherPerson, 'name'); // => false

API

propertyExists()

Return a boolean indicating whether the object has the specified property (as a direct property of that object)

Params

  • Object obj - An object to test
  • String key - A property name to test

Return

  • Boolean - Result

License

MIT © Philipp Alferov

npm i property-exists

Metadata

  • MIT
  • >=0.10.0
  • Philipp Alferov
  • released 10/10/2015

Downloads

Maintainers