has source npm

_.has(object, path)

Checks if path is a direct property of object.

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': { 'c': 3 } } };
var other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) });

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

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

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

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