Skip to content

Instantly share code, notes, and snippets.

@egoarka
Last active March 19, 2018 19:34
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 egoarka/9cc16c77f225d78eb173b0695700c9bb to your computer and use it in GitHub Desktop.
Save egoarka/9cc16c77f225d78eb173b0695700c9bb to your computer and use it in GitHub Desktop.
pureswap.js
const swap = (arr, id, id2) => {
const left = { [id2]: arr[id] };
const right = { [id]: arr[id2] };
return Object.assign([...arr], left, right);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment