pooyan pooyan - 4 months ago 32
Javascript Question

Send interval id as an argument to executing function

Is it possible to send interval id to executing function as an argument ? For example some thing like this:

var id= setInterval(myFunc.bind(null,id),1000);

What I am going to do is that in
I want to do some processing and clear interval if I need. I can't use global variable because it will be happened multiple time. And I know that I can use global array but it would a little a bit of time consuming because of my function logic. So I want to know if I can pass interval id as an argument to

this stackOverfllow link dosen't help me because there were no helpful answer.


I use this pattern:

function myFunc(host){

var host = {};
host.id = setInterval(myFunc.bind(null,host),1000);