Why Cant I Invoke A Function With Paremeters Multiple Time In Settimeout/setinterval
I am trying to invoke a function in my setinterval function like this function dosomething(variable) { console.log(variable); } setinterval(dosomething(variable), 2000) The abov
Solution 1:
You can use a anonymous function which will call the dosomething
method
setInterval(function(){dosomething(variable)}, 2000)
In your case you are calling dosomething
and then is passing the value returned by it to the setInterval()
Post a Comment for "Why Cant I Invoke A Function With Paremeters Multiple Time In Settimeout/setinterval"