summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-04-28 18:08:01 +0100
committerAndreas Kling <kling@serenityos.org>2020-04-28 20:15:38 +0200
commit823cc7bc1c206a60577021b4af2138eecdefb549 (patch)
tree5eee9680aa2f284f406d6653efd39b81e49e75df /Libraries/LibJS/Runtime
parentad8abce8a539475485700acd66aa6222b95c428b (diff)
downloadserenity-823cc7bc1c206a60577021b4af2138eecdefb549.zip
LibJS: Call Array.prototype.find() callback for empty elements
If the array value at the current index is empty, the callback will be called with undefined as value.
Diffstat (limited to 'Libraries/LibJS/Runtime')
-rw-r--r--Libraries/LibJS/Runtime/ArrayPrototype.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Libraries/LibJS/Runtime/ArrayPrototype.cpp
index 666b331ec5..9ee13271cc 100644
--- a/Libraries/LibJS/Runtime/ArrayPrototype.cpp
+++ b/Libraries/LibJS/Runtime/ArrayPrototype.cpp
@@ -452,12 +452,12 @@ Value ArrayPrototype::find(Interpreter& interpreter)
auto array_size = array->elements().size();
for (size_t i = 0; i < array_size; ++i) {
- if (i >= array->elements().size())
- break;
-
- auto value = array->elements().at(i);
- if (value.is_empty())
- continue;
+ auto value = js_undefined();
+ if (i < array->elements().size()) {
+ value = array->elements().at(i);
+ if (value.is_empty())
+ value = js_undefined();
+ }
MarkedValueList arguments(interpreter.heap());
arguments.append(value);