I'm browsing twitter and found this tweet:
https://twitter.com/_ericelliott/status/855598297939144704
Here is the code from the tweet:
const double = () => this.x * 2;
const numDouble = double.bind({ x: 5 });
numDouble();
When you run this snippet in console it'll produce NaN.
How?
Author is explicitly binding the value of x, but still it's showing NaN.
Author is also specifying that arrow function can't bind this. As i know that arrow function lexically bind the value of this form surrounding scope. Then why author is claiming so?
Please clarify my doubts and Thanks in advance for the help.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…