function buildUrl() {
var qs = "?debug=true";
with(location){
var url = href + qs;
}
return url;
}
buildUrl(); // it will work. WHY?
I am working through a "Professional JavaScript for Web Developers" by N. Zakas, and I came across this snippet. From my understanding with
is a statement that augments scope chain by pushing, in this case, location
object to the front.
It seems that url
local variable is assigned to a function activation object. Why isn't it assigned to location
?