JS Built-ins
Reflectgetbeginner

Reflect.get() β€” string value

πŸ“– 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() β€” returning a string

Reflect.get() can read string values from objects.

Challenge: Verify that Reflect.get({a: 'hello'}, 'a') returns 'hello'.

πŸ’‘ Hints (1)
  • β€’ `Reflect.get` is just a functional form of the property access operator.