Let's look at a chestnut first:
function buildUrl() { var qs = "?debug=true"; with(location){ var url = href + qs; console.log(location) ; } return url; } var result = buildUrl(); alert(result);
The with statement receives the location object, so its variable object contains all the properties and methods of the location object.