1let a = "red";
2let b = "blue";
3let c = a; // red
4a = b; //over-rides to blue
5b = c;
6
7console.log(a);
8console.log(b);
1//old method
2var a = 1;
3var b = 2;
4var temp = a;
5a = b;
6b = temp;
7console.log(a, b)
8//expected output: 2 1
9
10//new method(using destructuring method for swap)
11var x = 10;
12var y = 20;
13[y, x] = [x, y];
14console.log(y, x);
15//expected output: y = 10 and x = 20