August 1999
Intermediate to advanced
1488 pages
72h 53m
English
num1 - num2
The number to the right of the operator is subtracted from the number to the left of the operator. If either operand is a string, an attempt is made to convert the string to a number before performing the operation.
The code in Listing 6.1 creates a string out of the number "45". The string is converted to a number before being subtracted from the number 25.
<html> <script language="JavaScript"> <!–– Hide //Declare the number 45 as a string aString = new String("45"); //Subtract 25 from 45 answer = aString - 25; document.write("answer = (45-25)<br>"); ... |
Read now
Unlock full access