ES6 arrow pointing function and this

Function arrow (=>) : Function abbreviated
  • No parameters:() => {}
  • A single parameter:x => {}
  • A number of parameters:(x, y) => {}
  • Deconstruction parameters:({x, y}) => {}
  • Nesting: deployment pipeline mechanism
  • this point immobilization
    • Not because of internal binding thismechanism, but it did not own this, resulting in internal thisis the outer layer of code blocksthis
    • Because there is no this, and therefore can not be used as a constructor

Arrow function Mistakes

  • Function in the body thisis 定义时所在的对象not the使用时所在的对象
  • Allows thispoint immobilization, this feature is very beneficial to the callback function package
  • Not as 构造函数therefore can not use the arrow functionsnew命令
  • It can not be used yield命令, and therefore can not function as the arrowGenerator函数
  • Not available Arguments对象, this object does not exist (in a function in vivo rest/spread参数in place)
  • You must put parentheses around the outside of the object when the object is returned



Guess you like

Origin www.cnblogs.com/lijinxiao/p/11647500.html