Skip to content

Instantly share code, notes, and snippets.

@elliotlarson
Last active July 22, 2018 05:35
Show Gist options
  • Save elliotlarson/9687381fb96067880612ce8ee4d7ebe2 to your computer and use it in GitHub Desktop.
Save elliotlarson/9687381fb96067880612ce8ee4d7ebe2 to your computer and use it in GitHub Desktop.
// Creates a new array including the new item, turns it into a Set,
// which removes duplicates, and then turns it back to an array
const newCharacters = [...new Set([...characters, "Donald"])];
// Since "Donald" is a non-unique item, newCharacters will be:
// => ["Walter", "Jeffrey", "Donald"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment