3 ms·
I find some of them horribly obscure +new Date() // 1259359833574 Oh come on, magic constants? How do you check if that's the right number? function
by perlgeek 15y ago
I find some of them horribly obscure
+new Date() // 1259359833574
Oh come on, magic constants? How do you check if that's the right number?
function PrefixInteger(num, length) {
return (num / Math.pow(10, length)).toFixed(length).substr(2);
}
Is there no sprintf in Javascript? Or did I misunderstand what the function does?
- gimpf 15y ago> +new Date() // ... Title: Milliseconds since epoch
- s00pcan 15y agoYour browser likely has a javascript console, it's pretty useful: +new Date() 1309882329679 +new Date() 1309882331551 +new Date() 1309882332511
- walrus 15y ago"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).
- altano 15y agoRight, and it's equivalent to the more readable Number(new Date()) or more simply Date.now() if you don't need IE8 support.