JavaScript中可以在某个元素前使用 ‘+’ 号,这个操作是将该元素转换成Number类型,如果转换失败,那么将得到 NaN。

所以 +new Date 将会调用 Date.prototype 上的 valueOf 方法,而根据 MDN ,Date.prototype.value 方法等同于 Date.prototype.getTime() 。

相关文章:

  • 2021-12-28
  • 2022-01-18
  • 2021-10-29
  • 2022-12-23
  • 2021-12-22
  • 2022-02-10
  • 2021-07-16
  • 2021-06-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2021-08-23
  • 2022-12-23
相关资源
相似解决方案