Chapter 14 Answers
The most noticeable difference between Boolean values in PHP and JavaScript is that PHP recognizes the keywords
TRUE,true,FALSE, andfalse, whereas onlytrueandfalseare supported in JavaScript. Additionally, in PHP,TRUEhas a value of1andFALSEisNULL; in JavaScript they are represented bytrueandfalse, which can be returned as string values.The difference between unary, binary, and ternary operators is the number of operands each requires (one, two, and three, respectively).
The best way to force your own operator precedence is to surround the parts of an expression to be evaluated first with parentheses.
You use the identity operator when you wish to bypass JavaScript’s automatic operand type changing.
The simplest forms of expressions are literals (such as numbers and strings) and variables, which simply evaluate to themselves.
The three conditional statement types are
if,switch, and the?operator.Most conditional expressions in
ifandwhilestatements are literal or Boolean and therefore trigger execution when they evaluate toTRUE. Numeric expressions trigger execution when they evaluate to a nonzero value. String expressions trigger execution when they evaluate to a nonempty string. ANULLvalue is evaluated as false and therefore does not trigger execution.Loops using
forstatements are more powerful thanwhileloops because they support two additional parameters to control loop handling.The
withstatement takes an object as its parameter. Using ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access