Proposal: Selector/Select Expression

guest271314 guest271314 at gmail.com
Fri Jun 28 01:13:28 UTC 2019


> then the proposal is `array.find(.requestFrame)`.
>
> Since `.prop` is defined to be identically semantically to `o => o.prop`,
yes, the function `.prop` applied to an object with no property named
`prop` returns `undefined`.

Has the opposite, ```!``` and ```!!``` preceding ```.prop```, ```const d =
[a, b].find(!.c);``` or  ```const d = [a, b].find(!(.c));```  been
considered?

And ```async``` functions ```const d = [a, b].find(async (await(.c)));```?


On Fri, Jun 28, 2019 at 12:48 AM Bob Myers <rtm at gol.com> wrote:

> If the intent is to find the first entry with a truthy value for the
> `requestFrame` property, then the proposal is `array.find(.requestFrame)`.
> If the "wildcard" syntax is used, then it would be
> `array.find(?.requestFrame)`.
>
> On Thu, Jun 27, 2019 at 5:30 PM 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```?
>>
>
> Since `.prop` is defined to be identically semantically to `o => o.prop`,
> yes, the function `.prop` applied to an object with no property named
> `prop` returns `undefined`.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190628/14a6e9f4/attachment.html>


More information about the es-discuss mailing list