DEV Community

Discussion on: Destructuring JavaScript objects like a pro

Collapse
 
andreyvladikin profile image
Andrey Vladikin

let a = 1;
let b = 2;
[a, b] = [b, a];
=)

Collapse
 
timkor profile image
Timkor

Nice, didn't realise one could easily use this to swap variables!

Collapse
 
willamesoares profile image
Will Soares • Edited

Congrats :)
I should probably tell people not to look at comments before trying 😄