{ setX: function(x) { this._x = x; } } // works as expected { setX: (x) => { this._x = x; } } // haha nope, corrupts `window` probably
-
-
Replying to @qntm
var a = { setX: (x) => { this._x = x; } }; a.setX(67); console.log(a._x); // undefined console.log(window._x); // 67
3 replies 2 retweets 2 likes -
Replying to @qntm
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 reply 1 retweet 2 likes -
-
Replying to @qntm
In summary, JavaScript has two syntaxes for functions. One does what you'd expect, and the other does the opposite
2 replies 4 retweets 5 likes -
Replying to @qntm
Already knowing JavaScript reasonably well doesn't change this, it just flips which is which
1 reply 2 retweets 5 likes -
Replying to @qntm
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 replies 1 retweet 2 likes -
Replying to @webbedspace
@webbedspace@qntm whaaaaat where is that documented? literally the first time I hear about this1 reply 0 retweets 0 likes -
Replying to @allgebrah
@allgebrah@qntm Try going to the ES6 compat table https://kangax.github.io/compat-table/es6/ … and unfolding/reading the test code for unfamiliar features.1 reply 0 retweets 1 like
@webbedspace @qntm I do that from time to time but I appear to have missed the object literal extensions. Neat.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.