# lodash.hasIn

# Synopsis

_.hasIn(object, path)

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

# Since

4.0.0

# Arguments

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

# Returns

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

# Example

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

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

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

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

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

Last Updated: 1/6/2023, 8:32:34 AM