Proposal: Selector/Select Expression

Bob Myers rtm at
Sun Jun 23 06:04:57 UTC 2019

> In any event, re-read the proposal. Am certainly not opposed to the
JavaScript language being capable of golf by default. Is the gist of the
proposal to substitute ```|>```, and or ```.``` at ```const getEmail =;``` as the first character after ```=``` for `=>`, meaning
the initial ```.``` following ```=``` is interpreted as a function call,
equivalent to ```=>```? Can you include comments next to the examples at
the OP detailing what each character is intended to mean in JavaScript,
compared to the current specification of JavaScript?

This proposal has nothing to do with ```|>```. It is a variation of dot
notation, the classic notation ```o.p``` that has been a feature of JS
since its inception, to treat ```.p``` as a function (not a  function call)
taking one argument and returning the value of the property ```p``` in that
object. To put it a different way, if the object normally preceding the dot
is omitted, the construct is treated as a property picking function. It is
not a matter of the dot necessarily having to follow an equal sign, or
having some special meaning only that context; ```.p``` not preceded by an
object is a function regardless of the context. To my knowledge, there is
no ambiguity in this notation. In other words, there is no case in which a
dot not following an expression and followed by an identifier is anything
other than a syntax error at present--please correct me if I'm wrong.

Although not mentioned in the brief propsoal, there is no logical reason
that the analogous property access syntax ```.[prop]``` could not be
allowed. There also does not seem to any reason to prohibit the use of this
construct for arrays, so ```.[0]``` could be the "head" function people
have been talking about for years.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list