Ruan Yifeng http://es6.ruanyifeng.com/#docs/reflect
the MDN there are some simple introduction https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Reflect
not recommend direct learn es6, learning to be a ladder. Today to learn Proxy, might be used in their own framework. Usually less than the basic is
this knowledge is nodeJs of
MDN documentation easier not as Ruan Yifeng article.
Reflect first over the side of the API. He said that any demand requires more knowledge to supplement.
The Proxy clear on the line.
At first to explain what a reflex
reflector is not virtual entities. It corresponds to a virtual copy.
The method of a total of 13
first look get method
to get the value of the name of the object obj with the reflection method get.
It can be obtained by myObject.baz to value his baz if you want to run on another object.
The second object is not baz
demand is to call on the object baz baz is not the
result returned 8
way call with es5 method calls, but will complain. baz is a property is not a function. Can not call
Do not reflect the full similar needs.
Provided that c is a function. So you can directly call
Get two uses of summary
1 is a two parameter, three parameters 2
set
By changing the set value of name
The set bar to the second object reflector
Set 2
apply
For the minimum of two numbers.
Receiving n ... args parameter will get the argument to call Math.min, but is by way of apply to call. To transfer a call when this is Math, of course, you can pass this. The latter is what we want to pass args parameter.
With reflect.apply
There are examples of good writing on personal know almost
https://zhuanlan.zhihu.com/p/24778807
second parameter is optional, here we pass undefined
Here are three ways for the minimum.
So why not just use Math.min.apply it?
Make an assumption. The syntax of the left is not legitimate.
Is understood to have become the object of a method Reflect manner, but also additional receiver receives a parameter
look at these processes can be understood as target.apply
construct
proxy
proxy will be frequently used Reflect
End
42 minutes, and ended