On Tue, Aug 28, 2012 at 9:59 AM, Maciej Stachowiak <[email protected]> wrote:

>
> On Aug 26, 2012, at 4:30 PM, Brendan Eich <[email protected]> wrote:
>
> > Rick Waldron wrote:
> >>> But Array.of is not. Maybe Array.new is a good name.
> >> Array.of is unambiguous with the current ES specification
> >
> > Array.new is ok too, though -- no problem with a reserved identifier as
> a property name. It's darn nice for Rubyists.
>
> Another possibility is Array.create, following the pattern of
> Object.create. "of" seems like a funky name for a constructor, to my taste.
>

True, but I'd rather see Array.create as a fix for the "one argument Array
constructor", i.e. creating an array of the specified length, without
holes. For example:

Array.create = function (length) {
  if (length === 1) return [undefined]

  return Array.apply(null, Array(length))
}

There's been some discussion of that earlier, actually [1].

My 2 cents goes to Array.fromElements, conveys very well what it does.

However, I'm still not quite sure what the use case is for this. For code
generation, if you know how many elements there are and what they are
enough to put them in the Array.of(...,...,...) call, why not just use
[...,...,...]? Unless it's supposed to be used for converting array-likes
to arrays, where I really don't think this is the best function signature.
For the dart example, why not just use [] and you avoid the gotcha?

Cheers,
Jussi

[1] https://mail.mozilla.org/pipermail/es-discuss/2012-July/023974.html
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to