Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 3
    1st/2nd example is no union at all + 1st example blows up the stack for large Arrays + 3rd example is incredibly slow and consumes a lot of memory, since two intermediate Arrays have to be build + 3rd example can only be used for union with a known number of Arrays at compile time.
    – user6445533
    Commented Oct 10, 2016 at 10:13
  • so how you would do it ? Commented Oct 19, 2016 at 14:45
  • 9
    Note that for set can't deduplicate two objects that have the same key value pairs unless they are the same object references.
    – Jun
    Commented Jan 5, 2018 at 2:16
  • should be accepted answer for the modern of Javascript. Commented Mar 14, 2018 at 9:21
  • 18
    Does not work with an array of objects, as it'll only merge object references and doesn't care if the objects themselves are equal.
    – W Biggs
    Commented Mar 7, 2019 at 19:12