Access values from dynamic array via another function
<p>I have a function that sets bunch of <code>setTimeout</code> functions. All functions are added to Array <code>funcs</code>; nevertheless, when I try to stop them using <code>stopplay().clearTimeout</code> the array has no values.</p>

<p>How to access those functions and <code>clearTimeout</code> on them?</p>

<pre><code>var funcs = new Array();    

function playWithDelay(){   
    for (var i = 0; i &lt; PlayDatesArray.length; i++) { 
        funcs[i] = createfunc(i); 
    } 

    for (var j = 0; j &lt; PlayDatesArray.length; j++) { 
        funcs[j]();
    } 
}

function createfunc(i) { 
    return function() {        
        setTimeout(function(){            
        //my function
      }, i*1500);        
    }; 
}

function stopplay(){    
    alert(this.funcs.count);
    for (var i = 0; i&lt; funcs.count; i++){ 
        //things I tried
        var tmpFunction = funcs[i]; 
        //funcs[i].splice(i, 1);
        clearTimeout(tmpFunction);
        clearTimeout(funcs[i]);
        funcs[i]=tmpFunction;
    }    
}
</code></pre>
