HTML and CSS Reference
In-Depth Information
Table G-7 Order Of Precedence
Operator
Symbol
Precedence
Parentheses/brackets/dot
( ) [ ] . new
highest
Increment/negate/misc
11 - - ! + - ~ delete typeof void
Multiply/divide/modulo
* / %
Addition/subtraction
1 -
Shift
<< >> >>>
Comparison
< < 5 > > 5 in instanceof
Equality/Identity
55 ! 555 ! 55 ! 5 555
Bitwise AND
&
Bitwise XOR
^
Bitwise OR
|
Logical and
&&
Logical or
||
Conditional
?:
Assignment operators
5 15 - 5 * 5 / 5 % 5
Multiple evaluation
,
lowest
JavaScript Statements
Statements are used to write JavaScript instructions. Table G-8 summarizes the JavaScript
statements.
Table G-8 JavaScript Statements
Statement
Description
;
Used to separate statements, when used as an empty statement returns normal.
block
A block of JavaScript statements delimited by a pair of braces { }.
break
Exits switch statements and loops. Transfers program control to the statement line following the
switch statement or following the terminated loop.
comment
Notations that explain what a script does. Comments are ignored by the interpreter. Single-line
comments begin with //. Multiple-line comments begin with /* and end with */.
const
Identifies a declared constant value.
continue
Halts execution of a block of statements in a while or for loop and continues execution of the
loop with the next iteration.
do...while
Executes the block of statements in a loop until the test condition evaluates to false. Statements
in a loop execute at least once.
debugger
Will cause a breakpoint to occur when code is run in a debugger, otherwise, it has no effect.
finally
Executes a block of statements after the try and catch block of statements execute. The finally
block of statements executes whether or not an exception is thrown. A good use for the finally
block of statements is to allow a graceful failure.
for
Creates a loop that consists of three optional expressions, enclosed in parentheses and separated
by semicolons, followed by a block of statements executed in the loop. The test to terminate a
loop is done before the block of statements in the loop executes.
for...in
Iterates a specified variable over all the properties of an object. For each distinct property,
JavaScript executes the specified statements.
for...of
Iterates through object property line arrays and array-like objects (Gecko engine only).
Search WWH ::




Custom Search