Created
September 20, 2019 13:43
-
-
Save giovanniantonaccio/e2a2a4744dbd3d6b6746cca0cd5f0e33 to your computer and use it in GitHub Desktop.
Swap two integers
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
x = 24 | |
y = 99 | |
// Traditional way: | |
x = x + y | |
y = x - y | |
x = x - y | |
// if using ES6 this can be done using destructuring assignment array matching: | |
// [x, y] = [y, x] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment