Variáveis de troca de JavaScript
var a = 5;
var b = 3;
[a, b] = [b, a];
TC5550
var a = 5;
var b = 3;
[a, b] = [b, a];
let a = "red";
let b = "blue";
let c = a; // red
a = b; //over-rides to blue
b = c;
console.log(a);
console.log(b);
//old method
var a = 1;
var b = 2;
var temp = a;
a = b;
b = temp;
console.log(a, b)
//expected output: 2 1
//new method(using destructuring method for swap)
var x = 10;
var y = 20;
[y, x] = [x, y];
console.log(y, x);
//expected output: y = 10 and x = 20