function BuildUrl () {var qs = "? Debug=true"; with (location) {var url = href + qs;}
return URL; } console.log (BuildUrl ())
Here, the WITH statement receives the location object, so its variable object contains all the properties and methods of the Location object, and the variable object is added to the front end of the scope chain. A variable QS is defined in the BuildUrl () function. When the variable href is referenced in the WITH statement (actually referencing location.href), it can be found in the variable object of the current execution environment. When referring to the variable QS, the variable that is defined in BuildUrl () is referenced in the variable object in the function environment. As for the inside of the WITH statement, a variable named URL is defined, so the URL becomes part of the function execution environment, so it can be returned as the value of the function.
Because of the with method, the URL also becomes the function buildurl environment variable
JS Extended Scope Chain