Julian Hollmann Julian Hollmann - 2 years ago 63
Javascript Question

+new Date() - Is this good practice?

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"?

Answer Source

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:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download