你不知道的js——数组 join

你可能对使用数组的 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"
posted @ 2019-07-11 15:14  Liaofy  阅读(406)  评论(0编辑  收藏  举报