What exactly is the local scope defined outside of a function?
Consider the following code:
<cfscript>
local.madVar2 = "Local scope variable";
function madness() {
var madVar = "madness variable";
madVar2 = "madness two variable";
writeOutput("local: <BR>");
writeDump(local);
writeOutput("========================================= <BR>");
writeOutput("local.madVar2: <BR>");
writeDump(local.madVar2);
writeOutput("<BR>========================================= <BR>");
writeOutput("madVar2: <BR>");
writeDump(madVar2);
writeOutput("<BR>========================================= <BR>");
writeOutput("variables.madVar2: <BR>");
writeDump(variables.madVar2);
writeOutput("<BR>========================================= <BR>");
}
</cfscript>
Changing the madVar2 assignment by adding the var
keyword, like this:
function madness() {
var madVar = "madness variable";
var madVar2 = "madness two variable";
Will yield this output: