You're right but it only creates one array actually: a temp array [b, a]. JS then destructures it to assign values to a and be respectively.
[b, a]
This is what code looks like after being transpiled:
var a = 12; var b = 13; var _b; _b = [b, a], a = _b[0], b = _b[1];
Yes, it uses more memory but we're talking about 2 numbers here so the diff in memory footprint is very minimal and not worth loosing readability.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You're right but it only creates one array actually: a temp array
[b, a].JS then destructures it to assign values to a and be respectively.
This is what code looks like after being transpiled:
Yes, it uses more memory but we're talking about 2 numbers here so the diff in memory footprint is very minimal and not worth loosing readability.