Skip to content

Instantly share code, notes, and snippets.

@dan-laskowski
Created May 5, 2021 12:09
Show Gist options
  • Save dan-laskowski/ea3e19fbd139aa7209d1db9ae8197674 to your computer and use it in GitHub Desktop.
Save dan-laskowski/ea3e19fbd139aa7209d1db9ae8197674 to your computer and use it in GitHub Desktop.
[Swap the values of 2 variables] #javascript #js #swap #variables
// Swap the values of 2 variables
let a = 1;
let b = 2;
[a, b] = [b, a];
// Result:
// a = 2
// b = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment