SyntaxFix
Write A Post
Hire A Developer
Questions
ES6 array destructuring is used to swap two variables. See example
var [x,y]=[1,2]; [x,y]=[y,x];
Easier way possible with :
x === 1 and y === 2; But after destructuring, x is y, i.e. 2, and y is x, i.e. 1.
x === 1
y === 2
x
y
2
1