_.has

_.has(object, path)

Checks if path is a direct property of object.

Since

0.1.0

Arguments

  1. object (Object): The object to query.
  2. path (Array|string): The path to check.

Returns

(boolean): Returns true if path exists, else false.

Example

var object = { 'a': { 'b': 2 } };

var other = _.create({ 'a': _.create({ 'b': 2 }) });
 
_.has(object, 'a');
// => true
 
_.has(object, 'a.b');
// => true
 
_.has(object, ['a', 'b']);
// => true
 
_.has(other, 'a');
// => false
doc_Lodash
2016-11-27 16:37:28
Comments
Leave a Comment

Please login to continue.