how to deal with asynchronous function?
<p>I have two asynchronous objects fn1 and fn2 and sometimes I want to run them synchronously.</p>

<p>For simplicity I wrote the code in this way:</p>

<pre><code>var fn1 = function () {
    setTimeout(function () {
        console.log("fn1");
    },200);
};

var fn2 = function () {
    setTimeout(function () {
        console.log("fn2");
    },100);
};

fn1();
fn2(); 
</code></pre>

<p>but let's suppose is not possible to modify the fn1 and fn2 object. </p>

<p>What is the best way to run fn2 only when fn1 has finished to be executed?</p>
