|
JavaScript 2.0
Core Language
Statements
|
Thursday, November 11, 1999
Most of the behavior of statements is the same as in JavaScript 1.5. Differences are highlighted below.
;;;;;;A box has the syntax:
box { Statement ... Statement }A box behaves like a regular block except that it forms its own scope. Variable and function definitions without a Visibility prefix inside the box belong to that box instead of the global scope or the enclosing function, class, or box.
A block can be annotated with a Visibility prefix as follows:
{ Statement ... Statement }Such a block behaves like a regular block except that every declaration inside that block (but not inside any enclosed function, class, box, or nested visibility-specifying block) that does not have an explicit Visibility prefix uses the Visibility prefix given by the block.
Visibility-specifying blocks are useful to define several items without having to repeat a Visibility prefix for each one. For example,
class foo {
field z:integer;
public field a;
private field b;
public method f() {}
public method g(x:integer) {}
}
is equivalent to:
class foo {
field z:integer;
public {
field a;
private field b;
method f() {}
method g(x:integer) {}
}
}
if ParenthesizedExpression StatementabbrevNoShortIf else StatementabbrevNoShortIfThe semicolon is optional before the else.
The semicolon is optional before the closing while.
|
Waldemar Horwat Last modified Thursday, November 11, 1999 |