Rights Reserved. 8 The script Element and Commenting Your Scripts The type attribute specifies the MIME type of the script as well as the scripting language used in the script—in this case, a text file written in javascript. In HTML5, the default MIME type for a <script> is "text/html", so you can omit the type attribute from your <script> tags. You’ll see it in legacy HTML documents with embedded JavaScripts.
Rights Reserved. 12 The parentheses following the name of a method contain the arguments that the method requires to perform its task (or its action) Every statement should end with a semicolon
(also known as the statement terminator),
although none is required by JavaScript JavaScript is case sensitive Not using the proper uppercase and lowercase letters is a syntax error
Rights Reserved. 31 The next script creates a dynamic welcome page that obtains the user’s name, then displays it on the page. The script uses another predefined dialog box from the window object—a prompt dialog—which allows the user to enter a value that the script can use. Figure 6.5 presents the script and sample output.
Rights Reserved. 45 Our next script illustrates another use of prompt dialogs to obtain input from the user. Figure 6.7 inputs two integers (whole numbers, such as 7, –11, 0 and 31914) typed by a user at the keyboard, computes the sum of the values and displays the result.
Rights Reserved. 55 The basic arithmetic operators (+, -, *, /, and %) are binary operators, because they each operate on two operands JavaScript provides the remainder operator, %,
Rights Reserved. 60 Equality operators both have the same level of precedence, which is lower than the precedence of the relational operators. The equality operators associate from left to