[a, b] = [b, a];
// program to swap variables
let x = 4;
let y = 7;
// swapping variables
[x, y] = [y, x];
console.log(x); // 7
console.log(y); // 4
var a = 1,
b = 2;
b = [a, a = b][0];
var a = 5;
var b = 3;
[a, b] = [b, a];
let a = 1;
let b = 3;
[a, b] = [b, a];
console.log(a); // 3
console.log(b); // 1
const arr = [1,2,3];
[arr[2], arr[1]] = [arr[1], arr[2]];
console.log(arr); // [1,3,2]
let a = "red";
let b = "blue";
let c = a; // red
a = b; //over-rides to blue
b = c;
console.log(a);
console.log(b);