美文网首页
javascript中 +new Date()使用

javascript中 +new Date()使用

作者: duziten | 来源:发表于2017-11-02 14:38 被阅读0次

    +对于之后的日期对象进行加法运算,倒是触发了日期对象valueof()方法,所以最终得到的是日期对象的毫秒数,也就是时间戳。

    varnow =newDate, time =now.getTime();

    console.log(time==now.valueOf());//true

    console.log(time==+now);//true

    相关文章

      网友评论

          本文标题:javascript中 +new Date()使用

          本文链接:https://www.haomeiwen.com/subject/lhgopxtx.html