Bug 227939

Summary: Implement Array.prototype.findLast and Array.prototype.findLastIndex
Product: WebKit Reporter: Devin Rousso <hi>
Component: JavaScriptCoreAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, hi, joepeck, keith_miller, mark.lam, msaboff, ross.kirsling, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
[Patch] WIP
none
Patch
none
Patch
none
Patch none

Description Devin Rousso 2021-07-13 20:05:28 PDT
`Array.prototype.findLast` and `Array.prototype.findLastIndex` just advanced to TC39 stage 3

Proposal: <https://github.com/tc39/proposal-array-find-from-last>
Spec: <https://tc39.es/proposal-array-find-from-last/index.html>

```
const array = [{ value: 1 }, { value: 2 }, { value: 3 }, { value: 4 }];

array.find(n => n.value % 2 === 1); // { value: 1 }
array.findIndex(n => n.value % 2 === 1); // 0

array.findLast(n => n.value % 2 === 1); // { value: 3 }
array.findLastIndex(n => n.value % 2 === 1); // 2
```
Comment 1 Devin Rousso 2021-07-13 21:02:24 PDT
Created attachment 433476 [details]
[Patch] WIP
Comment 2 Yusuke Suzuki 2021-07-13 22:52:07 PDT
Comment on attachment 433476 [details]
[Patch] WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=433476&action=review

r=me

> Source/JavaScriptCore/builtins/ArrayPrototype.js:269
> +        var kValue = array[i];

I like the name like `element` instead of `kValue` even though it is derived from the spec's name since the name is not suitable for WebKit's coding style.
Comment 3 Yusuke Suzuki 2021-07-13 22:52:37 PDT
Comment on attachment 433476 [details]
[Patch] WIP

Can you add tests in JSTests/stress?
Comment 4 Devin Rousso 2021-07-14 13:01:29 PDT
Created attachment 433521 [details]
Patch
Comment 5 Devin Rousso 2021-07-14 14:27:08 PDT
Created attachment 433528 [details]
Patch
Comment 6 Devin Rousso 2021-07-14 17:47:11 PDT
Created attachment 433547 [details]
Patch
Comment 7 EWS 2021-07-14 20:12:00 PDT
Committed r279937 (239681@main): <https://commits.webkit.org/239681@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 433547 [details].
Comment 8 Radar WebKit Bug Importer 2021-07-14 20:13:17 PDT
<rdar://problem/80610784>