Created
April 15, 2022 04:13
-
-
Save esase/7288c4f2dbd1c61ba6eb9a0be9ed4743 to your computer and use it in GitHub Desktop.
Swap two variables using XOR
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
let a = 2; | |
let b = 4; | |
a = a ^ b; | |
b = a ^ b; | |
a = a ^ b; | |
console.log(a, b); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment