I want to use a global variable for using as argument for two or more functions:
$(document).ready(function(){
function foo(x){
var z = '#'+ x ;
// use function bar(y,z) insde;
}
function bar(y,z){
//
}
});
In practice, bar function cant see the z argument. Is there any way to define “z” as a global variable?
Thanks
One solution:
As you can see, the z variable is local to the ready handler. The foo and bar functions have access to it.
However, this may or may not be the best solution. That depends on how the foo and bar functions are used (where are they called from).