Skip to content

Instantly share code, notes, and snippets.

@battmanz
Created June 19, 2017 05:25
Show Gist options
  • Select an option

  • Save battmanz/d42d3224c99d76d780f68daaa6a87338 to your computer and use it in GitHub Desktop.

Select an option

Save battmanz/d42d3224c99d76d780f68daaa6a87338 to your computer and use it in GitHub Desktop.
Functions that can be used in place of Set mutator methods.
const set = new Set(['A', 'B', 'C']);
// Instead of: set.add('D');
const set2 = new Set([...set, 'D']);
// Instead of: set.delete('B');
const set3 = new Set([...set].filter(key => key !== 'B'));
// Instead of: set.clear();
const set4 = new Set();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment