mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
LibJS: Make Array.prototype.lastIndexOf slightly more spec compliant
This commit is contained in:
parent
44174a44bd
commit
c7aaf40a35
1 changed files with 7 additions and 4 deletions
|
@ -1047,13 +1047,16 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::last_index_of)
|
|||
return Value(-1);
|
||||
i32 from_index = length - 1;
|
||||
if (vm.argument_count() >= 2) {
|
||||
from_index = vm.argument(1).to_i32(global_object);
|
||||
double from_argument = vm.argument(1).to_integer_or_infinity(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (from_index >= 0)
|
||||
from_index = min(from_index, length - 1);
|
||||
if (vm.argument(1).is_negative_infinity()) {
|
||||
return Value(-1);
|
||||
}
|
||||
if (from_argument >= 0)
|
||||
from_index = min(from_argument, length - 1.);
|
||||
else
|
||||
from_index = length + from_index;
|
||||
from_index = length + from_argument;
|
||||
}
|
||||
auto search_element = vm.argument(0);
|
||||
for (i32 i = from_index; i >= 0; --i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue