Pure win: Array.from and Array.of

Brendan Eich brendan at mozilla.com
Sun Jul 10 11:44:22 PDT 2011


On Jul 10, 2011, at 10:40 AM, Dmitry A. Soshnikov wrote:

> On 10.07.2011 21:23, Brendan Eich wrote:
>> 
>> On Jul 10, 2011, at 10:18 AM, Rick Waldron wrote:
>> 
>>> The more I think about it, I still can't come up with any really exciting use cases where Array.of would outshine anything that already exists. I say strike it from the wishlist.
>> 
>> Higher-order programming with Array as constructing-function bites back for the single-number-argument case. That's where Array.of helps.
>> 
> 
> You mean when `Array` itself is passed as an argument?
> 
> var o = (function (ArrayConstructor, ...rest) {
>     return ArrayConstructor(...rest);
> })(Array, 10, 20, 30);

Yes. Now consider the case where you leave out the 20 and 30.

/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110710/653c1282/attachment.html>


More information about the es-discuss mailing list