mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibJS: Skip undefined and null in join_array_with_separator()
This it being used in Array.prototype.{join,toString}() - and now adhering to the spec: [undefined, null].join() === ","
This commit is contained in:
parent
86810a4b02
commit
6d6cd64689
3 changed files with 10 additions and 2 deletions
|
@ -226,8 +226,9 @@ static Value join_array_with_separator(Interpreter& interpreter, const Array& ar
|
|||
for (size_t i = 0; i < array.elements().size(); ++i) {
|
||||
if (i != 0)
|
||||
builder.append(separator);
|
||||
if (!array.elements()[i].is_empty())
|
||||
builder.append(array.elements()[i].to_string());
|
||||
auto value = array.elements()[i];
|
||||
if (!value.is_empty() && !value.is_undefined() && !value.is_null())
|
||||
builder.append(value.to_string());
|
||||
}
|
||||
return js_string(interpreter, builder.to_string());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue