Created
March 1, 2019 04:08
-
-
Save bioid/91c0b11f668a3a167e5c559ccefa3e68 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function xorswap(a,b) { | |
console.log(`a: ${a}, b: ${b}`) | |
b = b^a; | |
a = b^a; | |
b = b^a; | |
console.log(`a: ${a}, b: ${b}`) | |
} | |
let a = 3, | |
b = 10; | |
xorswap(a,b); | |
// a: 3, b: 10 | |
// a: 10, b: 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment