News for hackers. Stuff that matters.
Re:A re-introduction to JavaScript by bluesnowmonkey on Saturday May 09, 2015 @12:07PM (#9516746)
Another way to cast to a Number is the bitwise-or operator. It has the useful property of always yielding a number.

    '42' | 0;      // 42
    NaN | 0;       // 0
    null | 0;      // 0
    undefined | 0; // 0
    false | 0;     // 0
    true | 0;      // 1
Re:A re-introduction to JavaScript by eddyb on Saturday May 09, 2015 @12:27PM (#9516811)
Bitwise operations don't produce Numbers (f64), but signed integers (i32).
Re:A re-introduction to JavaScript by ougawouga on Saturday May 09, 2015 @04:37PM (#9517617)
> produce...signed integers

Well, except for right logical shifts.

Re:A re-introduction to JavaScript by Touche on Saturday May 09, 2015 @12:47PM (#9516877)
It always yields an integer, so it's useful if you know you want an integer.