[Contents] [Previous] [Next] [Index]

Chapter 3
Statements

This chapter describes all JavaScript statements. JavaScript statements consist of keywords used with the appropriate syntax. A single statement may span multiple lines. Multiple statements may occur on a single line if each statement is separated by a semicolon.

Syntax conventions: All keywords in syntax statements are in bold. Words in italics represent user-defined names or statements. Any portions enclosed in square brackets, [ ], are optional. {statements} indicates a block of statements, which can consist of a single statement or multiple statements delimited by a curly braces { }.

Table 3.1 lists statements available in JavaScript.

Table 3.1 JavaScript statements.  
break
Statement that terminates the current while or for loop and transfers program control to the statement following the terminated loop.

comment
Notations by the author to explain what a script does. Comments are ignored by the interpreter.

continue
Statement that terminates execution of the block of statements in a while or for loop, and continues execution of the loop with the next iteration.

delete
Deletes an object's property or an element of an array.

do...while
Executes its statements until the test condition evaluates to false. Statement is executed at least once.

export
Allows a signed script to provide properties, functions, and objects to other signed or unsigned scripts.

for
Statement that 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.

for...in
Statement that iterates a specified variable over all the properties of an object. For each distinct property, JavaScript executes the specified statements.

function
Statement that declares a JavaScript function name with the specified parameters. Acceptable parameters include strings, numbers, and objects.

if...else
Statement that executes a set of statements if a specified condition is true. If the condition is false, another set of statements can be executed.

import
Allows a script to import properties, functions, and objects from a signed script which has exported the information.

labeled
Provides an identifier that can be used with break or continue to indicate where the program should continue execution.

return
Statement that specifies the value to be returned by a function.

switch
Allows a program to evaluate an expression and attempt to match the expression's value to a case label.

var
Statement that declares a variable, optionally initializing it to a value.

while
Statement that creates a loop that evaluates an expression, and if it is true, executes a block of statements.

with
Statement that establishes the default object for a set of statements.


[Contents] [Previous] [Next] [Index]

Last Updated: 10/31/97 12:29:59


Copyright © 1997 Netscape Communications Corporation