Skip to content

Instantly share code, notes, and snippets.

@jmsevold
Created January 21, 2016 19:41
Show Gist options
  • Save jmsevold/cded7b86e30655131be9 to your computer and use it in GitHub Desktop.
Save jmsevold/cded7b86e30655131be9 to your computer and use it in GitHub Desktop.
Remove an item from an array without mutating array
var list = ['a', 'b', 'c','d'];
var removeFromArray = (list,index) => {
var before = list.slice(0, index);
var after = list.slice(index + 1, list.length);
var result = before.concat(after);
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment