JS Built-ins
Reflecthasbeginner

Reflect.has() β€” existing key returns true

πŸ“– Usage Example
const obj = { a: 1 }
console.log(Reflect.has(obj, 'a'))  // β†’ true
console.log(Reflect.has(obj, 'b'))  // β†’ false
// Equivalent to: 'a' in obj

Reflect.has() checks whether an object has a property, equivalent to the in operator.

Reflect.has(target, key)

Reflect.has() is the functional equivalent of the in operator.

Challenge: Verify that Reflect.has({x: 1}, 'x') returns true.

πŸ’‘ Hints (1)
  • β€’ `Reflect.has(target, key)` is equivalent to `key in target`.