Skip to content

Instantly share code, notes, and snippets.

@gengns
Last active July 8, 2018 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gengns/e5ab737c0698ac7d0a1ccd23d34a1e3f to your computer and use it in GitHub Desktop.
Save gengns/e5ab737c0698ac7d0a1ccd23d34a1e3f to your computer and use it in GitHub Desktop.
Swap the first and last element in an array without temporary variable or ES6 swap method [a, b] = [b, a]
[a.pop(), ...a.slice(1), a.shift()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment