Settimeout Calling Function Inside Function - Scope-issue
So, the problem is that I have a function inside a function that needs to be called by setTimeout. That doesn't work however because setTimeout will assume that the function it cal
Solution 1:
function general(){
function saysomething(){
console.log('hi there');
}
setTimeout(saysomething, 1000);
}
Solution 2:
Not positive this is what you mean but you can pass the variables when you call the function in the setTimeout
function f1(){
var a='1';
var b='b';
setTimeout(function(){f2(a,b);},1000)
}
function f2(a,b){
alert(a + b);
}
f1();
Post a Comment for "Settimeout Calling Function Inside Function - Scope-issue"