Randomblue Randomblue - 1 year ago 60
Node.js Question

How do I construct a Set with an Array

I am playing with

in Node.JS v0.11.3 and the
flag. The API works fine, I can
, etc. I have however not been able to initialise a set with an array. I have tried (as prompted by the MDN page)

var mySet = new Set([1, 1, 2]);

How can I convert an array to a set? Is MDN outdated? Has Node.JS simply not implemented the feature?

Answer Source

The v8 implementation of the Set constructor does not yet support the iterator and comparator arguments mentioned in ยง15.16.1.1 of the current draft of the Harmony specification, and node uses v8 as its JavaScript interpreter.

As a band-aid, you can use the simplesets package.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download