Reflect

Reflect.get

Gets the value of a property on an object, similar to target[propertyKey] but as a function

Syntax

JavaScript
Reflect.get(target, propertyKey, receiver?)

Parameters

ParameterTypeDescription
targetobjectThe target object to get the property from
propertyKeystring | symbolThe name of the property
receiveranyThe value of this for getters

Return Value

The value of the property

Examples

Basic Usage
const obj = { x: 1, y: 2 }
console.log(Reflect.get(obj, 'x')) // 1
Practical Example
const arr = [10, 20, 30]
console.log(Reflect.get(arr, 1)) // 20
console.log(Reflect.get(arr, 'length')) // 3
Advanced Usage
const handler: ProxyHandler<object> = {
  get(target, prop, receiver) {
    console.log(`get ${String(prop)}`)
    return Reflect.get(target, prop, receiver)
  }
}

Understanding Reflect.get

The Reflect.get method in JavaScript gets the value of a property on an object, similar to target[propertyKey] but as a function. It belongs to the Reflect object and is one of the most widely used methods for working with reflect values in modern JavaScript and TypeScript applications.

The method signature is Reflect.get(target, propertyKey, receiver?). It accepts 3 parameters: target, propertyKey, receiver. When called, it returns the value of the property. Understanding when and how to use get() helps you write more expressive, readable code.

Common use cases for Reflect.get include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like reflect-set, reflect-has, proxy-constructor, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Reflect.get is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Reflect Methods

Other methods in the Reflect object

Related Tools

More Reflect Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.