Conversation

Replying to
{ setX: function(x) { this._x = x; } } // works as expected { setX: (x) => { this._x = x; } } // haha nope, corrupts `window` probably
3
1
Replying to
var a = { setX: (x) => { this._x = x; } }; a.setX(67); console.log(a._x); // undefined console.log(window._x); // 67
3
2
Replying to
Of course if you're using both a setter and a getter it can take you quite a while to work out what's going on here -_-
1
2
Replying to
In summary, JavaScript has two syntaxes for functions. One does what you'd expect, and the other does the opposite
2
5
Replying to
Already knowing JavaScript reasonably well doesn't change this, it just flips which is which
1
5
Replying to
If you're wondering how you actually do arrow function methods, the accepted answer on Stack Overflow is "You can't, this is impossible"
3
2