`of` operator ES7 proposal from Ian Bicking

Bergi a.d.bergi at web.de
Mon Mar 30 19:45:57 UTC 2015


Brendan Eich schrieb:
>  From https://plus.google.com/+IanBicking/posts/PbXDtNF9Gg6:
>
> Huh, "for (attr in obj)" goes along with "if (attr in obj)", but "for
> (item of array)" doesn't have an equivalent "if (item of array)"
>
> It's obvious in hindsight. An `of` operator …

I would like such an operator as well, but I can see a big problem with 
this proposal: "of" is not a reserved keyword.
And it certainly has its usage as an identifier name already, most 
prominently: Array.of.
The fantasyland applicatives 
<https://github.com/fantasyland/fantasy-land#applicative> do have such a 
method as well. I found a few uses of it in github code 
<https://github.com/search?l=javascript&q=%22var+of+%3D+%22&ref=searchresults&type=Code> 
(most of those thousands are false positives or a particular test case, 
this example 
<https://github.com/ELLIOTTCABLE/from/blob/fb19155abbf39e91a532537599d3d16f592e16b6/lib/from-new.js#L96> 
is not).

  Bergi


More information about the es-discuss mailing list