Skip to content

Instantly share code, notes, and snippets.

@MidasXIV
Created October 22, 2019 05:15
Show Gist options
  • Save MidasXIV/9fa04c6baa055607323cb1b7f3867c96 to your computer and use it in GitHub Desktop.
Save MidasXIV/9fa04c6baa055607323cb1b7f3867c96 to your computer and use it in GitHub Desktop.
let a = 34, b = 89;
console.log(`OLD - a :: ${a} | b :: ${b}`); // OLD - a :: 34 | b :: 89`
// Swap two variables
// let temp = a;
// a = b;
// b = temp;
// Destructuring assignment
[a,b] = [b,a];
console.log(`NEW - a :: ${a} | b :: ${b}`); // NEW - a :: 89 | b :: 34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment