LibJS: Make Array.prototype.at return undefined on empty slot

This commit is contained in:
davidot 2021-06-13 18:09:59 +02:00 committed by Linus Groh
parent 6c13cc67c6
commit 2d87d5dab9
Notes: sideshowbarker 2024-07-18 12:16:13 +09:00

View file

@ -1486,7 +1486,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::at)
}
if (index.has_overflow() || index.value() >= length)
return js_undefined();
return this_object->get(index.value());
return this_object->get(index.value()).value_or(js_undefined());
}
}