`of` operator ES7 proposal from Ian Bicking

Axel Rauschmayer axel at rauschma.de
Mon Mar 30 06:36:06 UTC 2015

* Name-wise, is `has` a possibility? It feels more intuitive and I don’t think the duality with `in` matters (given that `for-in` will probably rarely be used in the future, due to `for-of` and `Map`).

* Will it ever be possible to define arbitrary infix operators? If yes, should this operator wait until that feature is available?

> On 30 Mar 2015, at 07:20, 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

Dr. Axel Rauschmayer
axel at rauschma.de

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150330/9c5e2e84/attachment-0001.html>

More information about the es-discuss mailing list