News for hackers. Stuff that matters.
Re:Advanced Javascript tips and tricks by perlgeek on Tuesday July 05, 2011 @08:51AM (#2729606)
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?
Re:Advanced Javascript tips and tricks by walrus on Tuesday July 05, 2011 @10:45PM (#2732402)
"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).
Re:Advanced Javascript tips and tricks by altano on Wednesday July 06, 2011 @12:50AM (#2732611)
Right, and it's equivalent to the more readable

    Number(new Date())
or more simply

    Date.now()
if you don't need IE8 support.
Re:Advanced Javascript tips and tricks by gimpf on Tuesday July 05, 2011 @09:12AM (#2729668)
> +new Date() // ...

Title: Milliseconds since epoch

Re:Advanced Javascript tips and tricks by s00pcan on Tuesday July 05, 2011 @12:13PM (#2730369)
Your browser likely has a javascript console, it's pretty useful:

  +new Date()
  1309882329679
  +new Date()
  1309882331551
  +new Date()
  1309882332511