BUPKIS
    Preparing search index...

    Function hasValueDeep

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

      Uses strict equality (===) to compare values, with special handling for empty objects. Handles circular references by tracking visited objects to prevent infinite recursion.

      Parameters

      • obj: unknown

        The object, array, or value to search within

      • value: unknown

        The value to search for (using strict equality, with special empty object handling)

      • visited: WeakSet<object> = ...

        Internal set for circular reference detection

      Returns boolean

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

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

      hasValue(obj, 2);
      hasValue(obj, 3);
      hasValue(obj, {});
      hasValue(obj, '1');
      hasValue(obj, 999);