Top Level Array Generics

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