paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 389 forks source link

Clarify Set([iterable]) versus new Set(list, of, items) #304

Closed ljharb closed 9 years ago

ljharb commented 9 years ago

The spec is clear but inconsistent on Set([1, 2, 3]) versus Set(1, 2, 3) versus new Set([1, 2, 3]) versus new Set(1, 2, 3) - specifically, how many items do each of these have?

The current spec seems to indicate the answers are 3, TypeError, 1, and 3, respectively.

domenic commented 9 years ago

My understanding is that you can't call Set as a function, and that trying to pass the constructor a non-iterable object will throw. So that would give TypeError, TypeError, 3, TypeError. Can check spec to confirm...

ljharb commented 9 years ago

Cleared it up - I misunderstood some of the spec WebIDL language. I'll clear up the TypeError messages in the shim so this is clearer.