You can cast a string to a number using:
num = Number(str);
A shorter way to convert a string into a number is using the unary + operator:
num = +str;
If the string needs to be converted to a number and there is other code in the statement where further calculations are to be applied you can specify it as (+str) so as to ensure that the + isn't misinterpreted.
You can cast a number to a string using:
str = String(num);
A shorter way to convert a number to a string is to use the concatenate operator:
str = ""+num;
Because one of the values is a string (admittedly an empty one) it forces the other value to convert to a string in order to concatenate the two strings together.
This article written by Stephen Chapman, Felgall Pty Ltd.