The with statement sets the scope for an object.
The syntax is as follows:
with (expression) statement;
The following code:
var q = location.search.substring(1); var h = location.hostname; var u = location.href;
can be rewritten using the with statement as follows:
with(location){ var q = search.substring(1); var h = hostname; var u = href; }
In the code, the with statement is used with the location object.
In strict mode, the with statement is not allowed and is considered a syntax error.