Explorar o código

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

davidot %!s(int64=4) %!d(string=hai) anos
pai
achega
2d87d5dab9
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp

+ 1 - 1
Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp

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