你可能对使用数组的 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"

相关文章:

  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2021-09-02
  • 2021-06-01
  • 2021-06-08
  • 2021-11-03
相关资源
相似解决方案