+新日期() - 这是一个好习惯吗? [英] +new Date() - Is this good practice?

查看:125
本文介绍了+新日期() - 这是一个好习惯吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我们今天在公司讨论了 + new Date()是不是很好的做法。
有些人喜欢这种方式超过 new Date()。getTime()

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().

在我看来,这是非常方便的,但在另一方面,人们会说它更难阅读。

In my opinion, this is pretty convenient but on the other side one would say it's harder to read.

除了显而易见的对于不熟悉的人更难理解之外是否有任何利弊与一元运算符?

Are there any pros or cons besides the obvious "It's harder to understand for people not familiar with the unary operator"?

推荐答案

在考虑了这一点后的最后几年我得出结论,表现不是这里有因素。

After thinking about this the last years a lot I came to the conclusion that performance is not a factor here.

所以这里是我更喜欢的可读性解决方案:

So here is the solution I prefer in terms of readability:

Date.now();

这篇关于+新日期() - 这是一个好习惯吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆