Javascript 简明教程
JavaScript - Handler
JavaScript Proxy Handlers 用于定义对对象执行的基本操作的自定义行为。通过定义处理程序,您可以覆盖基本操作的默认行为。以下是常见代理处理程序方法:apply()、construct()、get()、has()等。
The JavaScript Proxy Handlers are used to define custom behavior for fundamental operations performed on objects. By defining handlers, you can override the default behavior of fundamental operations. Following are the common proxy handler methods: apply(), construct(), get(), has(), etc.
JavaScript Handlers
以下是 JavaScript 处理程序的方法 −
Following are the methods of JavaScript Handler −
Sr.No. |
Name & Description |
1 |
apply()Allows you call a function with particular arguments and context. |
2 |
construct()Allows you to define custom behavior for fundamental operations on an object. |
3 |
defineproperty()It is used to define new properties or modify existing ones on an object. |
4 |
deleteproperty()It is used as a trap for the delete operator. |
5 |
get()It is a trap for getting a property value. |
6 |
getownpropertydescriptor()It is a trap for the [id="GetOwnProperty"] object internal method. |
7 |
getprototypeof()It is a trap for the internal method. |
8 |
has()It is used to “hide” any property that you want. |
9 |
isextensible()It is used to determine whether the new property can be added or not the target object. |
10 |
ownkeys()It is a trap for the [id="OwnPropertyKeys"] object internal method. |
11 |
set()It is a trap for the [id="Set"] object internal method. |
12 |
setprototypeof()Allows you set the prototype of a specified object to another object to another object. |