I simply can't understand why it gives this error.
Here is what I tested on my chrome's console:
> var mySet;
<- undefined
> mySet = new Set;
<- Set {}
> mySet.add('foo', 'bar', 'baz') // Worked as expected
<- Set {"foo"} // just the first argument was added
> ['bar', 'baz'].forEach(mySet.add)
X-> VM1529:1 Uncaught TypeError:
Method Set.prototype.add called on incompatible receiver undefined(…)
Thanks in advance.
forEach(mySet.add.bind(mySet))
-.add()
must usethis
internally...['bar', 'baz'].forEach(mySet.add, mySet)