title: How to use if expression in Promise.all()?
body: <p>I want to use <code>Promise.all()</code> to handle two promise object, but the second is inner a <code>if</code> expression. How to handle this situation?</p>
  
  <p>It looks like this:</p>
  
  <pre><code>functionA(); 
  
  if(true) {
      functionB(); 
  }
  </code></pre>
  
  <p><code>functionA()</code> and <code>functionB()</code> both return a promise object. In normal case, I could use</p>
  
  <pre><code>Promise.all([
      functionA(),
      functionB()
  ]).then(resule =&gt; {
      console.log(result[0]);  // result of functionA
      console.log(result[1]);  // result of functionB
  })
  </code></pre>
  
  <p>But how to handle with the <code>if</code> expression? Should I wrap the <code>if(true){functionB()}</code> in a <code>new Promise()</code>?</p>