Function constants for Identity and No-op

Andrea Giammarchi andrea.giammarchi at
Wed Aug 10 16:41:29 UTC 2016

Kevin that "from somewhere else" has same problems cross-realm `instanceof`
would have, you can't always trust that and if you want to map identities
just do it instead of adding extra code ;-)

On Wed, Aug 10, 2016 at 5:24 PM, Kevin Reid <kpreid at> wrote:

> [no quotes because I'm not replying to anyone in particular]
> An advantage that has not been mentioned yet, of having a canonical
> function instance for particular behaviors, is that it allows for some
> library-level optimization by being able to know what a function does
> (which is otherwise opaque). For a simple example:
> = function (f) {
>     if (f === Function.IDENTITY) {
>         return this;
>     }
> a new collection with f applied to elements and return it...
> };
> Of course, it would be silly to write, but a
> caller might be passing the function from somewhere else.
> (I only intend to point out this one benefit, not to claim it justifies
> the feature entirely.)
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list