Skip to content

Instantly share code, notes, and snippets.

@giovanniantonaccio
Created September 20, 2019 13:43
Show Gist options
  • Save giovanniantonaccio/e2a2a4744dbd3d6b6746cca0cd5f0e33 to your computer and use it in GitHub Desktop.
Save giovanniantonaccio/e2a2a4744dbd3d6b6746cca0cd5f0e33 to your computer and use it in GitHub Desktop.
Swap two integers
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