Converting to number fast way
Converting strings to numbers is extremely common. The easiest and fastest (jsPerf) way to achieve that would be using the +
(plus) operator.
var one = '1';
var numberOne = +one; // Number 1
You can also use the -
(minus) operator which type-converts the value into number but also negates it.
var one = '1';
var negativeNumberOne = -one; // Number -1

THE JSTIPS FLASHCARDS
Learn JavaScript twice as fast. Remember forever.
Five years worth of JavaScript that you can learn in just a few weeks. This is the most complete and efficient flashcards ever created.
GET THE CARDS NOW
MEET THE NEW JSTIPS BOOK
You no longer need 10+ years of experience to get your dream job.
Use the 100 answers in this short book to boost your confidence and skills to ace the interviews at your favorite companies like Twitter, Google and Netflix.
GET THE BOOK NOW