Calls the provided callbackFn once for each own enumerable key (string and symbol) in the
supplied value. The callback can stop iteration early by returning -1.
This helper works with plain objects, arrays, and functions while safely ignoring
null and undefined values.
Note: Unlike objForEachKey, this helper also iterates enumerable symbol keys via
Object.getOwnPropertySymbols. Use forEachOwnKeySafe when iterating untrusted input
to filter out unsafe keys like __proto__, constructor, and prototype.
If reading a property value throws (for example a getter that throws an exception), the exception is caught and
the key is skipped (the callbackFn is not called for it), so a single throwing getter does not stop the iteration of
the remaining keys, and a helper which copies the values (eg. objExtend or objDeepCopy) doesn't copy
undefined for it (replacing an existing value). Since 0.20.0, previously the exception stopped the iteration.
Calls the provided
callbackFnonce for each own enumerable key (string and symbol) in the supplied value. The callback can stop iteration early by returning-1.This helper works with plain objects, arrays, and functions while safely ignoring
nullandundefinedvalues.Note: Unlike objForEachKey, this helper also iterates enumerable symbol keys via
Object.getOwnPropertySymbols. Use forEachOwnKeySafe when iterating untrusted input to filter out unsafe keys like__proto__,constructor, andprototype.If reading a property value throws (for example a getter that throws an exception), the exception is caught and the key is skipped (the
callbackFnis not called for it), so a single throwing getter does not stop the iteration of the remaining keys, and a helper which copies the values (eg. objExtend or objDeepCopy) doesn't copyundefinedfor it (replacing an existing value). Since 0.20.0, previously the exception stopped the iteration.