Why does the following snippet of code convert my variable of type string
to type number
?
let stringInteger = '42';
let convertToInteger = +stringInteger;
console.log(typeof convertToInteger)
More specifically, why does prefixing +
to the variable have this effect? Note, I'm asking why not what it does.