In JavaScript, a plus symbol (+
) in front of a variable casts it to a number
For example, +"1"
returns 1
.
If the value can’t be converted to number type, it will return NaN
.
For example , +"a"
or +{}
return NaN
.