Java Reference
In-Depth Information
Conditional
The following table lists conditional statements for JavaScript as well as the version in which they were
introduced.
Statement
Introduced
Description
if
JavaScript 1.2
Executes a block of code if a specifi ed condition is true .
else
JavaScript 1.2
The second half of an if statement. Executes a block of code if the
result of the if statement is false .
switch
JavaScript 1.2
Specifi es various blocks of statements to be executed depending
on the value of the expression passed in as the argument.
Declarations
These keywords declare variables or functions in JavaScript code.
Statement
Introduced
Description
var
JavaScript 1.0
Used to declare a variable. Initializing it to a value is optional at
the time of declaration.
function
JavaScript 1.0
Used to declare a function with the specifi ed parameters, which
can be strings, numbers, or objects. To return a value, the func-
tion must use the return statement.
Loop
Loops execute a block of code while a specifi ed condition is true .
Statement
Introduced
Description
do…while
JavaScript 1.2
Executes the statements specifi ed until the test condition after
the while evaluates to false. The statements are executed at
least once because the test condition is evaluated last.
for
JavaScript 1.0
Creates a loop controlled according to the three optional expres-
sions enclosed in the parentheses after the for and separated
by semicolons. The fi rst of these three expressions is the initial-
expression, the second is the test condition, and the third is the
increment-expression.
for…in
JavaScript 1.0
Used to iterate over all the properties of an object using a vari-
able. For each property the specifi ed statements within the loop
are executed.
Search WWH ::




Custom Search