Re:Advanced Javascript tips and tricks
by perlgeek on Tuesday July 05, 2011 @08:51AM
(#2729606)
I find some of them horribly obscure
Oh come on, magic constants? How do you check if that's the right number?
Is there no sprintf in Javascript? Or did I misunderstand what the function does?
[ Parent
| on HN ]
"1259359833574" isn't a magic constant. JavaScript uses // for comments. The number is just an example of the possible output of the expression "+new Date()" (specifically, it was the time at which the author of that page evaluated the expression).
Right, and it's equivalent to the more readable
Number(new Date())
or more simply Date.now()
if you don't need IE8 support.> +new Date() // ...
Title: Milliseconds since epoch