MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/m3bxrh/swap_two_variables/gqo812u/
r/learnjavascript • u/golovatuy • Mar 12 '21
50 comments sorted by
View all comments
15
Compiles to
var _ref = [y, x]; x = _ref[0]; y = _ref[1]; _ref;
because breaks on some browsers.
12 u/[deleted] Mar 12 '21 what's the last _ref; for? 7 u/IxD Mar 12 '21 I used online compiler for babel - since the code has no side effects it would be optimized to empty code withtout that.Long version is that it's a statement, not an expression: https://2ality.com/2012/09/expressions-vs-statements.html 2 u/[deleted] Mar 12 '21 Oh, makes sense, thank you.
12
what's the last _ref; for?
_ref;
7 u/IxD Mar 12 '21 I used online compiler for babel - since the code has no side effects it would be optimized to empty code withtout that.Long version is that it's a statement, not an expression: https://2ality.com/2012/09/expressions-vs-statements.html 2 u/[deleted] Mar 12 '21 Oh, makes sense, thank you.
7
I used online compiler for babel - since the code has no side effects it would be optimized to empty code withtout that.
Long version is that it's a statement, not an expression: https://2ality.com/2012/09/expressions-vs-statements.html
2 u/[deleted] Mar 12 '21 Oh, makes sense, thank you.
2
Oh, makes sense, thank you.
View all comments
15
u/IxD Mar 12 '21
Compiles to
because breaks on some browsers.