• Checks if path is a direct property of object.

    Type Parameters

    • T
    • K extends PropertyName

    Parameters

    • object: T

      The object to query.

    • path: K

      The path to check.

    Returns object is T & {
        [P in PropertyName]: P extends keyof T
            ? T[P<P>]
            : Record<string, unknown> extends T ? T[keyof T] : unknown
    } & { "[uniqueSymbol]": unknown }

    Returns true if path exists, else false.

    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
  • Type Parameters

    • T

    Parameters

    Returns boolean