The proxy's handler object is a placeholder object which contains traps for proxies.
Methods
All traps are optional. If a trap has not been defined, the default behavior is to forward the operation to the target.
handler.getPrototypeOf()
- A trap for
Object.getPrototypeOf
. handler.setPrototypeOf()
- A trap for
Object.setPrototypeOf
. handler.isExtensible()
- A trap for
Object.isExtensible
. handler.preventExtensions()
- A trap for
Object.preventExtensions
. handler.getOwnPropertyDescriptor()
- A trap for
Object.getOwnPropertyDescriptor
. handler.defineProperty()
- A trap for
Object.defineProperty
. handler.has()
- A trap for the
in
operator. handler.get()
- A trap for getting property values.
handler.set()
- A trap for setting property values.
handler.deleteProperty()
- A trap for the
delete
operator. handler.ownKeys()
- A trap for
Object.getOwnPropertyNames
andObject.getOwnPropertySymbols
. handler.apply()
- A trap for a function call.
handler.construct()
- A trap for the
new
operator.
Some non-standard traps are obsolete and have been removed.
Specifications
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Proxy Object Internal Methods and Internal Slots' in that specification. |
Standard | Initial definition. |
ECMAScript Latest Draft (ECMA-262) The definition of 'Proxy Object Internal Methods and Internal Slots' in that specification. |
Living Standard | The enumerate handler has been removed. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
apply | 49 | 12 | 18 | No | 36 | 10 |
construct | 49 | 12 | 18 | No | 36 | 10 |
defineProperty | 49 | 12 | 18 | No | 36 | 10 |
deleteProperty | 49 | 12 | 18 | No | 36 | 10 |
enumerate | No | No | 37 — 47 | No | No | No |
get | 49 | 12 | 18 | No | 36 | 10 |
getOwnPropertyDescriptor | 49 | 12 | 18 | No | 36 | 10 |
getPrototypeOf | No | No | 49 | No | No | No |
has | 49 | 12 | 18 | No | 36 | 10 |
isExtensible | ? | ? | 31 | No | ? | ? |
ownKeys | 49 | 12 | 181 | No | 36 | 10 |
preventExtensions | 49 | 12 | 22 | No | 36 | 10 |
set | 49 | 12 | 18 | No | 36 | 10 |
setPrototypeOf | ? | ? | 49 | No | ? | ? |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
apply | 49 | 49 | Yes | 18 | No | 36 | 10 |
construct | 49 | 49 | Yes | 18 | No | 36 | 10 |
defineProperty | 49 | 49 | Yes | 18 | No | 36 | 10 |
deleteProperty | 49 | 49 | Yes | 18 | No | 36 | 10 |
enumerate | No | No | No | 37 — 47 | No | No | No |
get | 49 | 49 | Yes | 18 | No | 36 | 10 |
getOwnPropertyDescriptor | 49 | 49 | Yes | 18 | No | 36 | 10 |
getPrototypeOf | No | No | No | 49 | No | No | No |
has | 49 | 49 | Yes | 18 | No | 36 | 10 |
isExtensible | ? | ? | ? | 31 | No | ? | ? |
ownKeys | 49 | 49 | Yes | 181 | No | 36 | 10 |
preventExtensions | 49 | 49 | Yes | 22 | No | 36 | 10 |
set | 49 | 49 | Yes | 18 | No | 36 | 10 |
setPrototypeOf | ? | ? | ? | 49 | No | ? | ? |
1. In Firefox 42, the implementation got updated to reflect the final ES2015 specification: The result is now checked if it is an array and if the array elements are either of type string or of type symbol. Enumerating duplicate own property names is not a failure anymore.
See also
Document Tags and Contributors
Tags:
Contributors to this page:
fscholz,
SphinxKnight,
fasttime,
kdex,
jwhitlock,
DanielHerr,
pnevyk,
ziyunfei,
arai
Last updated by:
fscholz,