Call javascript dynamic method in object
<p>If I create a Class with two method like following:</p>

<pre><code>var Car = function() {}
Car.prototype = {
    run: function() {
        alert('run');
    },
    stop: function() {
        alert('stop');
    }
}
</code></pre>

<p>And when the DOM is ready will call test() method,<br />
and this test() method will create a instance of Car and call the method of Car</p>

<pre><code>$(document).ready(function() {
    test("run");
});
function test(method) {
    var instance = new Car();
    // call instance.run()
}
</code></pre>

<p>I know I have to use apply() method, <br />
but I have tried lots of times and failed<br />
So, how can I use apply() method in Object?</p>
