this arrow functions, arguments Detailed

1, arrow function does not own this, arguments, super or new.target.
2, it's this, arguments are bound to the definition of the function of this outer layer and arguments, but not bound in the implementation process, so the change will not occur because of different callers.
3, the arrow you want to get the function parameter list into its own arguments, parameters must use the remaining notation.
4, arrows function expression more suitable for those places that would otherwise require anonymous function, and it can not be used as a constructor.

Here we validated to arguments, for example, this empathy

var obj = {}; 
obj.fn = function () { 
  the let arrow arrow = (args ...) => { 
    the console.log ( 'the parameter list:', arguments); // outer parameter list into 
    console. log ( 'remaining parameters:', args); // use the remaining parameter indicates the method itself obtained by the argument list 
  } 
  arrow arrow ( 4,5,6 ) 
} 

obj.fn ( l, 2,3)

The following is the output

The argument list: Arguments (3) [1, 2, 3, callee: ƒ, Symbol (Symbol.iterator): ƒ]
The remaining parameters: (3) [4, 5, 6]

We can see from the above verification arrow arrow function arguments using the parameter list acquired when, in fact, is obtained outer layer function arguments. And this is also a reason.

Guess you like

Origin www.cnblogs.com/jiangxiaoxi/p/12590668.html