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
This little beastie here is tap. A really useful function for quick-debugging chains of function calls, anonymous functions and, actually, whatever you just want to print.
Arrays are everywhere and with the new spread operators introduced in ECMAScript 6, you can do awesome things with them. In this post I will show you 3 useful tricks you can use when programming.
- Read More →