The with Statement

The with statement sets the scope within a particular object. The syntax is as follows:

with (expression) 

var qs =; 
var hostName = location.hostname;

The code above can be rewritten using the with statement:

    var qs = search.substring(1); 
    var hostName = hostname; 

In strict mode, the with statement is not allowed and is considered a syntax error.

  JavaScript Book 
    Language Basics  

  1. The if Statement
  2. The do...while Statement
  3. The while Statement
  4. The for Statement
  5. The for-in Statement
  6. Labeled Statements
  7. The break and continue Statements
  8. The with Statement
  9. The switch Statement