Reflect.get
Gets the value of a property on an object, similar to target[propertyKey] but as a function
Syntax
Reflect.get(target, propertyKey, receiver?)Parameters
| Parameter | Type | Description |
|---|---|---|
| target | object | The target object to get the property from |
| propertyKey | string | symbol | The name of the property |
| receiver | any | The value of this for getters |
Return Value
The value of the property
Examples
const obj = { x: 1, y: 2 }
console.log(Reflect.get(obj, 'x')) // 1const arr = [10, 20, 30]
console.log(Reflect.get(arr, 1)) // 20
console.log(Reflect.get(arr, 'length')) // 3const 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
Reflect.setSets the value of a property on an object, similar to target[propertyKey] = value but as a function
Reflect.hasReturns a boolean indicating whether the target object has the specified property, equivalent to the in operator
ProxyCreates a new Proxy object that wraps a target object and intercepts operations defined by a handler
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.