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

Re: Top Level Array Generics

From: David Bruant <bruant.d@gmail.com>
Date: Fri, 08 Nov 2013 19:27:45 +0100
Message-ID: <527D2D21.1000807@gmail.com>
To: Garrett Smith <dhtmlkitchen@gmail.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Le 07/11/2013 08:31, Garrett Smith a écrit :
> Also, Array.filter is NaN in Chrome.
... I don't even... Whoaaa... isNaN(Array.filter) is true in Firefox as 
well...

When you think you've seen it all...

David

>
>
> On Wed, Nov 6, 2013 at 11:31 PM, Garrett Smith <dhtmlkitchen@gmail.com 
> <mailto:dhtmlkitchen@gmail.com>> wrote:
>
>     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
>
>
>
>
> -- 
> Garrett
> @xkit
> ChordCycles.com <http://ChordCycles.com>
Received on Friday, 8 November 2013 18:28:36 UTC

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