Shortcut: String to number in JS

Put a + (plus) operator in front of a string to convert it into a number.

+'12' (string) => 12 (number)
let x = '40'; (string)
+x => 40 (number)

No comments:

Post a Comment

Power function

In C/C++ (and also other languages), we have the built in power function to raise a number to a given power. What if we need to calculate ...