Scope of var and variables
问题 If I have a function like <cfscript> function say(what) { var a = what; variables.b = what; return what; } </cfscript> I thought the scope of a was variables , but dumping variables returns just b . What is the scope of a? 回答1: Declaring a variable using the var keyword puts it into the local scope, not the variables scope. 回答2: This really is a comment, but it is way too long. Consider the following code <cfscript> function doMath() { var a = 1; local.b = 2; return a + local.b; } </cfscript>