+new Date() - Is this good practice?

前端 未结 5 1237
一整个雨季
一整个雨季 2020-12-12 22:37

So we had the Discussion today in our company about +new Date() being good practice or not. Some prefer this way over new Date().getTime().

5条回答
  •  半阙折子戏
    2020-12-12 23:08

    IMHO, when there isn't much difference in performance, legibility should always win out. We should all be practicing WCTR "writing code to be read." Therefore, for me, this is best practice:

    (new Date()).getTime();

提交回复
热议问题