re: Sets in ES6 - A Quick Guide VIEW POST


Some minor corrections:

  • You wrote foo.add(key, value) instead of foo.add(key) in your API overview.
  • You wrote "Sets do not have keys so they do not have a .keys()". Actually they do; it's just an alias for .values(). This is so that they provide the same iteration API functions as Maps, which can be useful when writing certain algorithms which will operate on container keys and/or values. Same reason Sets have .entries(). The important difference being that @@iterator maps to Map.entries() but Set.values().
code of conduct - report abuse