BUPKIS
    Preparing search index...

    Function hasKeyDeep

    • Recursively searches within an object, array, or any nested structure to find whether a specific key exists.

      Handles circular references by tracking visited objects to prevent infinite recursion.

      Parameters

      • obj: unknown

        The object, array, or value to search within

      • key: PropertyKey

        The key to search for

      • visited: WeakSet<object> = ...

        Internal set for circular reference detection

      Returns boolean

      True if the key is found anywhere in the structure, false otherwise

      const obj = { a: 1, b: { c: 2, d: [{ e: 3 }] } };

      hasKeyDeep(obj, 'c');
      hasKeyDeep(obj, 'e');
      hasKeyDeep(obj, 'x');