Jason Orendorff (2014-06-12T12:36:36.000Z)
On Wed, Jun 11, 2014 at 11:44 AM, Allen Wirfs-Brock
<allen at wirfs-brock.com> wrote:
> Array.from and Array.of have a non-throwing IsConstrutor test because they are designed to allow things like this:
>
> let of = Array.of;
> of(1,2,3,4,5);   //Equivalent to: Array.of(1,2,3,4,5)
>
> I don't recall why we provided that functionality.  It doesn't seem to me like a pattern we should want to encourage.

I think it was meant for functional programming; but FP is so poorly
supported by the rest of the standard library that it's not useful by
itself.

Array.of could test 'if the this value is undefined' rather than using
IsConstructor(). I like that. I can't put my finger on it, but I
suspect people will try to treat Array.of as a standalone function and
get the "undefined is not a constructor" error, and be baffled.

Back to the topic, it seems weird to go out of our way to expose
@@isRegExp and @@isConcatSpreadable and also go out of our way to hide
IsConstructor(). I don't like "does this object conform to this
protocol" tests, but they are a fact of life in real JS code.

-j
domenic at domenicdenicola.com (2014-06-20T19:30:55.588Z)
On Wed, Jun 11, 2014 at 11:44 AM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> I don't recall why we provided that functionality.  It doesn't seem to me like a pattern we should want to encourage.

I think it was meant for functional programming; but FP is so poorly
supported by the rest of the standard library that it's not useful by
itself.

Array.of could test 'if the this value is undefined' rather than using
IsConstructor(). I like that. I can't put my finger on it, but I
suspect people will try to treat Array.of as a standalone function and
get the "undefined is not a constructor" error, and be baffled.

Back to the topic, it seems weird to go out of our way to expose
@@isRegExp and @@isConcatSpreadable and also go out of our way to hide
IsConstructor(). I don't like "does this object conform to this
protocol" tests, but they are a fact of life in real JS code.