pooyan pooyan - 1 year ago 96
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.

Answer Source

I use this pattern:

function myFunc(host){

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download