In the following function:
foo = function(a){
if (!a) a = "Some value";
// something done with a
return a;
}
When "a" is not declared I want to assign a default value for use in the rest of the function, although "a" is a parameter name and not declared as "var a", is it a private variable of this function? It does not seem to appear as a global var after execution of the function, is this a standard (i.e. consistent) possible use?
return a || "Some value"instead ofif(!a) a = "some value"; return a;if(typeof a == "undefined")