mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibJS: Let Array.prototype.join() ignore additional arguments
I.e. array.join("x", "y", "z") === array.join("x") rather than array.join("x", "y", "z") === array.join()
This commit is contained in:
parent
9fc4ad2a52
commit
9f7a6e116a
2 changed files with 2 additions and 1 deletions
|
@ -239,7 +239,7 @@ Value ArrayPrototype::join(Interpreter& interpreter)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
String separator = ",";
|
String separator = ",";
|
||||||
if (interpreter.argument_count() == 1) {
|
if (interpreter.argument_count()) {
|
||||||
separator = interpreter.argument(0).to_string(interpreter);
|
separator = interpreter.argument(0).to_string(interpreter);
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -5,6 +5,7 @@ try {
|
||||||
|
|
||||||
assert(["hello", "friends"].join() === "hello,friends");
|
assert(["hello", "friends"].join() === "hello,friends");
|
||||||
assert(["hello", "friends"].join(" ") === "hello friends");
|
assert(["hello", "friends"].join(" ") === "hello friends");
|
||||||
|
assert(["hello", "friends", "foo"].join("~", "#") === "hello~friends~foo");
|
||||||
assert([].join() === "");
|
assert([].join() === "");
|
||||||
assert([null].join() === "");
|
assert([null].join() === "");
|
||||||
assert([undefined].join() === "");
|
assert([undefined].join() === "");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue