Javascript timestamp
I look for the best performance in my javascript code. And sometimes short sentences looks better and works slower. For example, we have several ways to get timestamp in JavaScript.
And looks like
new Date().getTime()
is almost twice faster then
+new Date()
And the last one is even slower then jQuery "now" function
$.now()
Here are the test on JsPerf
If you works with dates a lot then it makes sense to think of the fastest way.
Written by Aleksandr Denisenko
Related protips
2 Responses
Date.now() is faster when available. Check the edit of the JsPerf. http://jsperf.com/test-the-speed-of-now/3 :)
over 1 year ago
·
Date.now() is the best. Thanks for the good note!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#