Skip to main content

hasIn

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

Checks if path is a direct or inherited property of object.

Since​

4.0.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 = _.create({ 'a': _.create({ 'b': 2 }) });

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

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

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

_.hasIn('b', object);
// => false