Variabel swap JavaScript
var a = 5;
var b = 3;
[a, b] = [b, a];
TC5550
var a = 5;
var b = 3;
[a, b] = [b, a];
let a = 5, b = 6;
[a, b] = [b, a];
console.log(`${a} ${b}`);
Run code snippet