你可能对使用数组的 join 方法已经轻车熟路,但你也许不知道:

10.If element0 is undefined or null, let R be the empty String; otherwise, let R be ToString(element0).
https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.join

如果一个元素为 undefined 或 null,它会被转换为空字符串。

> [undefined,1,2].join()
< ",1,2"

相关文章: