Download JavaScript Demystified (Demystified) by Jim Keogh PDF

Logical Operators Logical operators (Table 2-4) are used to combine two logical expressions into one expression.

However, if either of these is false, then the third logical expression is false. When using the AND logical operator, both logical expressions on either side of the AND logical operator must be true for the combined logical expression to be true; otherwise, the combined logical expression is false. Figure 2-8 shows a JavaScript that prompts the user to enter a user ID, and Figure 2-9 shows a JavaScript that prompts the user to enter a password. The values entered by the user are compared to ScubaBob and diving, the valid user ID and password.

Var a = 10 var b = 2 a <= b CHAPTER 2 Variables, Operators, and Expressions Conditional Operator The conditional operator (also known as the ternary operator) (Table 2-7) is different from the other operators that you’ve learned about in this chapter. The conditional operator tells the browser to take a specific action after evaluating an expression. The conditional operator has three parts: The first part is a logical expression, which you’ll recall is an expression that evaluates to either true or false.

Download PDF sample

Rated 4.18 of 5 – based on 43 votes