Shijun He (2012-08-26T19:52:54.000Z)
domenic at domenicdenicola.com (2014-01-03T16:26:09.146Z)
On Sun, Aug 26, 2012 at 7:14 PM, Rick Waldron <waldron.rick at gmail.com> wrote: > If you replace that by using Array.of(), you avoid this "gotcha" So you still need some code like: ```js if (constructor === Array) return Array.of(rest) else return new construct(rest) ``` And of cause we can write it as: ```js if (constructor === Array) return [rest] ``` Or, maybe you mean we should write ```js o = ....(Array.of, 10) instead of o = ....(Array, 10) ``` But is this case strong enough to add such a simple function to standard library? > I'd argue that if code is extending ES built-ins with non-standard > properties, it accepts the risk that one day it may be in conflict. And if it should be added, could you choose a better name? `Array.isArray` is good example which will not introduce any ambiguity. But `Array.of` is not. Maybe `Array.new` is a good name.