Proxy get()
The handler.get() method is a trap for the internal [[Get]] method.
The handler.get() method is a trap for property accessors.
The handler.get() method is triggered when a property is read.
Example
get(obj, prop, receiver) {
return Reflect.get(obj, prop, receiver);
}
Triggered by:
proxy.property
proxy["property"]
object.property()
Syntax
handler.get(obj, prop ,receiver)
Parameters
| Parameter | Description |
|---|---|
| obj | Required. The target object. |
| prop | Required. The property to get. |
| receiver | The this value of the setter. Normally the Proxy itself. |
Return Value
| Type | Description |
|---|---|
| Value | The value of the property. |
Errors
| Type | Description |
|---|---|
| TypeError | Thrown if obj is not an object. |
Proxy Handler Methods:
handler.apply()
handler.construct()
handler.defineProperty()
handler.deleteProperty()
handler.get()
handler.getOwnPropertyDescriptor()
handler.getPrototypeOf()
handler.has()
handler.isExtensible()
handler.ownKeys()
handler.preventExtensions()
handler.set()
handler.setPrototypeOf()
Browser Support
handler.get() is an ECMAScript6 (ES6 2015) feature.
JavaScript 2015 is supported in all browsers since June 2017:
| Chrome 51 |
Edge 15 |
Firefox 54 |
Safari 10 |
Opera 38 |
| May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |