Chapter 15 Answers

Question 15-1

The most noticeable difference between Boolean values in PHP and JavaScript is that PHP recognizes the keywords TRUE, true, FALSE, and false, whereas only true and false are supported in JavaScript. Additionally, in PHP TRUE has a value of 1 and FALSE is NULL; in JavaScript they are represented by true and false, which can be returned as string values.

Question 15-2

Unlike PHP, no character is used (such as $) to define a JavaScript variable name. JavaScript variable names can start with and contain any uppercase and lowercase letters as well as underscores; names can also include digits, but not as the first character.

Question 15-3

The difference between unary, binary, and ternary operators is the number of operands each requires (one, two, and three, respectively).

Question 15-4

The best way to force your own operator precedence is to surround the parts of an expression to be evaluated first with parentheses.

Question 15-5

You use the identity operator when you wish to bypass JavaScript’s automatic operand type changing.

Question 15-6

The simplest forms of expressions are literals (such as numbers and strings) and variables, which simply evaluate to themselves.

Question 15-7

The three conditional statement types are if, switch, and the ? operator.

Question 15-8

Most conditional expressions in if and while statements are literal or Boolean and therefore trigger execution when they evaluate to TRUE. Numeric expressions trigger execution when they evaluate to a ...

Get Learning PHP, MySQL, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.