So I have a function that loops executing a function, example:
function(f){
var variable;
for(z = 0; z < 10; z++){
variable = "cool";
setInterval(f)
}
Btw, the real function is MUCH more complex than this but it's the same theory. I want to be able to execute the function in argument f and set some variables (ex. variable) so that this function can use them, in a whole this is the idea:
function say(f){
var variable = "hey";
setInterval(f);
}
say(function(){
alert(variable)
});
Here, one should get an alert box saying hey. That's the theory, but it wont work:
Variable "variable" isn't defined
The browser will probably just ignore the error and alert undefined.
But anyways, how do I "pass" the variable without changing the scope of it.