JS Built-ins
Reflecthasbeginner

Reflect.has() β€” check second key

πŸ“– 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() β€” multiple keys

Reflect.has() can check for any key in an object.

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

πŸ’‘ Hints (1)
  • β€’ `Reflect.has` checks the full prototype chain just like the `in` operator.