//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