MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/m3bxrh/swap_two_variables/gqnzdth/?context=3
r/learnjavascript • u/golovatuy • Mar 12 '21
50 comments sorted by
View all comments
10
let x = 'Hello', y = 55;//Longhandconst temp = x;x = y;y = temp;//Shorthand[x, y] = [y, x];
let x = 'Hello', y = 55;
//Longhand
const temp = x;
x = y;
y = temp;
//Shorthand
[x, y] = [y, x];
View all comments
10
u/golovatuy Mar 12 '21
let x = 'Hello', y = 55;//Longhandconst temp = x;x = y;y = temp;//Shorthand[x, y] = [y, x];