Issue #2246 - Implement Array find from last.

Based on the implementation from Mozilla bug 1704385.
This commit is contained in:
Job Bautista 2023-01-12 21:42:27 +08:00 committed by roytam1
commit bbb91e4833
5 changed files with 161 additions and 0 deletions

View file

@ -3191,6 +3191,10 @@ static const JSFunctionSpec array_methods[] = {
/* ES2022 additions */
JS_SELF_HOSTED_FN("at", "ArrayAt", 1,0),
/* ES2023 proposals */
JS_SELF_HOSTED_FN("findLast", "ArrayFindLast", 1,0),
JS_SELF_HOSTED_FN("findLastIndex", "ArrayFindLastIndex", 1,0),
JS_FS_END
};
@ -3356,6 +3360,8 @@ array_proto_finish(JSContext* cx, JS::HandleObject ctor, JS::HandleObject proto)
!DefineProperty(cx, unscopables, cx->names().fill, value) ||
!DefineProperty(cx, unscopables, cx->names().find, value) ||
!DefineProperty(cx, unscopables, cx->names().findIndex, value) ||
!DefineProperty(cx, unscopables, cx->names().findLast, value) ||
!DefineProperty(cx, unscopables, cx->names().findLastIndex, value) ||
!DefineProperty(cx, unscopables, cx->names().flat, value) ||
!DefineProperty(cx, unscopables, cx->names().flatMap, value) ||
!DefineProperty(cx, unscopables, cx->names().includes, value) ||