Can you bind 'this' in an arrow function?

前端 未结 11 2307
囚心锁ツ
囚心锁ツ 2020-11-22 03:09

I\'ve been experimenting with ES6 for a while now, and I\'ve just come to a slight problem.

I really like using arrow functions, and whenever I can, I use them.

11条回答
  •  自闭症患者
    2020-11-22 03:40

    From the MDN:

    An arrow function expression has a shorter syntax compared to function expressions and lexically binds the this value (does not bind its own this, arguments, super, or new.target). Arrow functions are always anonymous.

    This means you cannot bind a value to this like you want.

提交回复
热议问题