JS Built-ins
Reflectgetbeginner

Reflect.get() β€” array index

πŸ“– Usage Example
const obj = { name: 'Alice', age: 30 }
const name = Reflect.get(obj, 'name')
console.log(name) // β†’ 'Alice'

Reflect.get() retrieves the value of a property on an object, equivalent to obj[key].

Reflect.get() with arrays

Reflect.get() works on arrays too β€” use a numeric index as the key (as a string or number).

Challenge: Verify that Reflect.get([10, 20], 1) returns 20.

πŸ’‘ Hints (1)
  • β€’ `Reflect.get` works on any object including arrays.