Working with JavaScript Operators

What if you wanted to manipulate your data in JavaScript code? Say, for example, that you needed to multiple 219 by 45—how would you do it? In JavaScript, you can use the multiplication operator (*). Here's an example showing how this works:

Listing . ch06_05.html
 
<HTML>
    <HEAD>
        <TITLE>
            Using Operators In JavaScript
        </TITLE>
    </HEAD>

    <BODY>
        <CENTER>
            <H1>
                Using Operators In JavaScript
            </H1>
        </CENTER>

        <SCRIPT LANGUAGE="JavaScript">
            var result
					result = 219 * 45
					document.writeln("219 * 45 = " +  result)
        </SCRIPT>
    </BODY>
</HTML>

You can see the results of this code in Figure 6-5.

Figure 6-5. Using JavaScript operators in Internet Explorer.

As you might expect, there are many operators available in JavaScript. For ...

Get Real World XML now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.