variables - Javascript: Converting String to Number? -


Is there a way to change the number from a string?

For example, I have

  var str = "1";  

Can I change it

  var str = 1;    

Try str = parseInt (str, 10) < / P>

( Note : The second parameter is a symbol of Radix for parsing; in this case, your number will be parsed as decimal)

That is, however, that the word "type" is used in Javascript quite loosely, can you explain why you are worried about the type of variable?


Comments