Skip to content
Advertisement

Pass parameters in setInterval function

Please advise how to pass parameters into a function called using setInterval.

My example setInterval(funca(10,3), 500); is incorrect.

Advertisement

Answer

You need to create an anonymous function so the actual function isn’t executed right away.

setInterval( function() { funca(10,3); }, 500 );
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement