Beginner es6 A previous click event was rewritten as $(".btn").click(()=>{console.log(this)});This here points to the document, but if When using function, this points to the current element. How to change the point of this?
This question is a cliché. In conclusion, the this pointer in the arrow function has been fixed and points to the block-level scope of the current code rather than the caller's scope.
It is recommended to take a look at the arrow function of es6
The arrow function does not have its own
this
at all, but refers to the outerthis
This question is a cliché. In conclusion, the this pointer in the arrow function has been fixed and points to the block-level scope of the current code rather than the caller's scope.
Some related documents:
https://developer.mozilla.org...
http://www.infoq.com/cn/artic...