mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-25 15:39:55 +00:00
LibJS: Treat missing arg in Array.prototype.includes() as undefined
This commit is contained in:
parent
fbcfc8dcd0
commit
5db9becc4a
Notes:
sideshowbarker
2024-07-19 06:16:17 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/5db9becc4a5 Pull-request: https://github.com/SerenityOS/serenity/pull/2324 Reviewed-by: https://github.com/Dexesttp
2 changed files with 4 additions and 2 deletions
|
@ -422,8 +422,8 @@ Value ArrayPrototype::includes(Interpreter& interpreter)
|
||||||
if (!array)
|
if (!array)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
i32 array_size = static_cast<i32>(array->elements().size());
|
i32 array_size = array->elements().size();
|
||||||
if (interpreter.argument_count() == 0 || array_size == 0)
|
if (array_size == 0)
|
||||||
return Value(false);
|
return Value(false);
|
||||||
|
|
||||||
i32 from_index = 0;
|
i32 from_index = 0;
|
||||||
|
|
|
@ -5,6 +5,8 @@ try {
|
||||||
|
|
||||||
var array = ['hello', 'friends', 1, 2, false];
|
var array = ['hello', 'friends', 1, 2, false];
|
||||||
|
|
||||||
|
assert([].includes() === false);
|
||||||
|
assert([undefined].includes() === true);
|
||||||
assert(array.includes('hello') === true);
|
assert(array.includes('hello') === true);
|
||||||
assert(array.includes(1) === true);
|
assert(array.includes(1) === true);
|
||||||
assert(array.includes(1, -3) === true);
|
assert(array.includes(1, -3) === true);
|
||||||
|
|
Loading…
Reference in a new issue