Return true, if target owns a property with the given key.
The object to check.
The key to check for.
True if the target owns the property with the given key, otherwise false.
const obj = { a: 1, b: 2 };has(obj, 'a'); // returns truehas(obj, 'c'); // returns false Copy
const obj = { a: 1, b: 2 };has(obj, 'a'); // returns truehas(obj, 'c'); // returns false
Use the built-in Object.hasOwn(target, key), which this calls. Will be removed in goldies 6.0.
Object.hasOwn(target, key)
Return true, if target owns a property with the given key.