Dynamic function call (apply)
<p>I am trying to dynamically call a function inside of an object. Found the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/apply" rel="nofollow"><code>apply</code></a> function but not fully understanding it. Check out the code below, by triggering <code>Test.checkQueue()</code> it should in turn call <code>showSomething</code> "method". Thanks.</p>

<pre><code>var Test = {    
    , queue : [{action:'showSomething', id:'1234'},{action:'showOther', id:'456'}]
    , showSomething: function(what) {
        alert(what);    
    }
    , checkQueue : function() {
        console.log('checkQueue');
        console.log(this.queue);
        if (this.queue.length) {
            var do = this.queue.shift();
            console.log(do);
            // action.action(action.id);
            do.action.apply(this, do.id || []);
        }
    }

};
</code></pre>
