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
Create hash maps(without side effects) using
Object cloning is a tricky, full of edge-cases, endeavor. The reason is simple enough. Objects maintain internal state, and that is much abused. There are countless techniques, or better phrased, countless derivations of the same technique.