Skip to main content

has

_.has(path, object) # Ⓢ [Ⓣ][1] Ⓝ

Checks if path is a direct property of object.

Since​

0.1.0

Arguments​

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

Returns​

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

Example​

var object = { 'a': { 'b': 2 } };
var other = _.create({ 'a': _.create({ 'b': 2 }) });

_.has('a', object);
// => true

_.has('a.b', object);
// => true

_.has(['a', 'b'], object);
// => true

_.has('a', other);
// => false