1var first = 5;
2var second = 7;
3[first, second] = [second, first];
4console.log(first, second);
5//answer - 7 5
1let a = 1;
2let b = 2;
3let temp;
4
5temp = a;a = b;b = temp;
6a; // => 2
7b; // => 1
1function swap(x, y) {
2 var t = x;
3 x = y;
4 y = t;
5 return [x, y];
6}
7
8console.log(swap(2, 3));