`of` operator ES7 proposal from Ian Bicking

Michał Wadas michalwadas at gmail.com
Mon Mar 30 06:42:13 UTC 2015

First possible problem - "of" used in if statement can put iterator in
unexpected state or result in arbitrary side effects. Of course, code like
"piece.isKing()" can have side effects too, but any programmer comming from
any language is conscious of this danger. Using operator obsfucates this.
On Mar 30, 2015 7:20 AM, "Brendan Eich" <brendan at mozilla.org> wrote:

> From https://plus.google.com/+IanBicking/posts/PbXDtNF9Gg6:
> """
> Ian Bicking
> Shared publicly - Mar 24, 2015
> #Array
> 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)"
> There is a proposal I guess for a method, but only for ES7:
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/
> Reference/Global_Objects/Array/includes
> """
> It's obvious in hindsight. Wants a @@hasInstance-like protocol, not just
> desugaring to `includes` with operands transposed to receiver and argument.
> An `of` operator with unstratified symbol-named MOP hook helps various
> container-like objects cope with the vagaries of NaNs and indexOf /
> includes differences between arrays and strings, and (most winningly) lines
> up with for-of, as Ian points out, in a parallel to for-in and `in`.
> I'm sure it's worth some debate, perhaps someone will k.o. the idea with
> an objection I can't think of, but I like it.
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150330/1aa83017/attachment.html>

More information about the es-discuss mailing list