Proposal: Selector/Select Expression

Isiah Meadows isiahmeadows at gmail.com
Fri Jun 28 15:28:09 UTC 2019


If missing, the expectation is that it's return `undefined` just like how
`a.foo` returns `undefined` if `a` has no property `"foo"`. It's just
shorthand for `x => x.foo` and similar.

On Thu, Jun 27, 2019 at 20:30 guest271314 <guest271314 at gmail.com> wrote:

> How can the Selector/Select Expression be used with
> `Array.prototype.find()`? What happens when the property is not defined?
>
> For example using the same code for more than one browser
>
> ```
> const stream = [canvasStream, videoTrack].find(({requestFrame: _}) => _);
> ```
>
> the property `requestFrame` is either defined or not defined at
> ```canvasStream``` or ```videoTrack``` depending on the implementation.
> Although the assigned variable can be reduced to 1 character at
> destructuring assignment, there is still the redundancy of writing ```_```
> again on the right side of ```=>```.
>
> If the property is not found, is the result ```undefined```?
>
> What is the least amount characters necessary using Selector/Select
> Expression with ```find()```?
>
> ```
> const stream = [canvasStream, videoTrack].find(=.requestFrame);
> ```
>
> ?
>
> On Thu, Jun 27, 2019 at 8:48 PM Bob Myers <rtm at gol.com> wrote:
>
>> Not exactly, since the optional chaining operator is `?.` with no space
>> in between.
>>
>> On Thu, Jun 27, 2019 at 1:37 PM Simon Farrugia <simonfarrugia26 at gmail.com>
>> wrote:
>>
>>> Also, without a leading token, a selector expr with the optional
>>> chaining operator inside a ternary operator would be ambiguous.
>>>
>>> ```
>>>
>>> const contactSelector = true ? .contacts.email : .contacts.phone;
>>>
>>> ```
>>>
>>>
>>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-- 
-----

Isiah Meadows
contact at isiahmeadows.com
www.isiahmeadows.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190628/3d78ee49/attachment.html>


More information about the es-discuss mailing list