From 2d87d5dab91f4e58811e2b910f4c1f8e496bd46a Mon Sep 17 00:00:00 2001 From: davidot Date: Sun, 13 Jun 2021 18:09:59 +0200 Subject: [PATCH] LibJS: Make Array.prototype.at return undefined on empty slot --- Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 8dbc154a38..91f61a1d7c 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -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()); } }