Skip to content

Instantly share code, notes, and snippets.

@amoilanen
Created March 23, 2016 11:47
Show Gist options
  • Save amoilanen/01c3328a6c597af7f1e8 to your computer and use it in GitHub Desktop.
Save amoilanen/01c3328a6c597af7f1e8 to your computer and use it in GitHub Desktop.
Swapping variables using ES6 destructuring assignment
//JavaScript swapping variables
var x = 1, y = 2;
[x, y] = [y, x];
console.log("x = %s, y = %s", x, y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment