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

with

Establishes the default object for a set of statements. Within the set of statements, any property references that do not specify an object are assumed to be for the default object.

Implemented in

Navigator 2.0

Syntax

with (object){
   statements
}

Arguments

object
Specifies the default object to use for the statements. The parentheses around object are required.

statements
Any block of statements.

Examples

The following with statement specifies that the Math object is the default object. The statements following the with statement refer to the PI property and the cos and sin methods, without specifying an object. JavaScript assumes the Math object for these references.

var a, x, y
var r=10
with (Math) {
   a = PI * r * r
   x = r * cos(PI)
   y = r * sin(PI/2)
}


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

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


Copyright © 1997 Netscape Communications Corporation


Casa de Bender