JS Built-ins
Reflecthasbeginner

Reflect.has() β€” array index as 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() with array indices

Array indices are property keys. Reflect.has([1,2,3], 0) checks if index 0 exists.

Challenge: Verify that Reflect.has([1,2,3], 0) returns true.

πŸ’‘ Hints (1)
  • β€’ Array indices are numeric string keys on the array object.