Created
May 5, 2021 12:09
-
-
Save dan-laskowski/ea3e19fbd139aa7209d1db9ae8197674 to your computer and use it in GitHub Desktop.
[Swap the values of 2 variables] #javascript #js #swap #variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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