W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2013

Top Level Array Generics

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Wed, 6 Nov 2013 23:31:13 -0800
Message-ID: <CABZUbM39GZoGRhK+-rJPB0tqG1S4pxJYsx92HeLnTMoJz-i4mQ@mail.gmail.com>
To: "public-script-coord@w3.org" <public-script-coord@w3.org>
Present in Mozilla, top level generics put the Array prototype methods on
the global Array object and accept the first argument as the `this` value
for the method.

So instead of the very common:

 var filter = Array.prototype.filter;

 filter.call( "foo",
   function (ch) { return ch == "o"; });

There would be just:

 Array.filter("foo",
   function (ch) { return ch == "o"; }).join("");

Same thing; less code.
--
Garrett
@xkit
ChordCycles.com
Received on Thursday, 7 November 2013 07:31:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:19 UTC