Function constants for Identity and No-op

Alexander Jones alex at
Wed Aug 10 19:29:42 UTC 2016

Those spellings don't help when trying to visually parse a bunch of code
which already largely consists of dense punctuation, though, IMO.

On Wednesday, 10 August 2016, Tab Atkins Jr. <jackalmage at> wrote:

> On Wed, Aug 10, 2016 at 7:25 AM, Eli Perelman <eli at
> <javascript:;>> wrote:
> > Now obviously it would be trivial for me to declare these constants in
> > userland code like I already do, e.g. `const NOOP = () => {}`, but in
> > projects where it's needed in several files, I'll have to put that in a
> > module or re-declare everywhere. This is not a huge inconvenience but
> > something that could easily allocated for in the language.
> Mark's argument (which I agree with) is that `x=>x` and `()=>{}` are
> good *spellings* of "identity function" and "noop function".  It's
> immediately obvious what they do; `obj.doCallback(()=>{})` is about as
> easy to understand as `obj.doCallback(Function.noop)`.  The ID
> function is even simpler - `>x)` reads *extremely* well to
> me, equal or better than ``. If we were to reserve
> "id" and "noop" as bare global variables, I might agree that those
> were even better, but that's clearly out of the question.
> ~TJ
> _______________________________________________
> es-discuss mailing list
> es-discuss at <javascript:;>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list