Introduction to JavaScript

Type Conversion
Subtracting Strings and Numerics

Click this button to see the value in the sVariable2 variable, calculated by adding a string variable to a numeric variable:

Now click here to see what happens when you subtract a numeric value from a string:

NOTE: The same will hold true for multiplication and division. Try it for yourself!

<SCRIPT LANGUAGE="JavaScript">

var sVariable1 = "555";
var sVariable2 = sVariable1 + 10;
var sVariable3 = sVariable1 - 10;

</SCRIPT>

<FORM>
     <INPUT TYPE="button" VALUE="sVariable2: String + Numeric" onClick="alert(sVariable2)">
     <INPUT TYPE="button" VALUE="sVariable3: String - Numeric" onClick="alert(sVariable3)">
</FORM>