title: delay using promise instead of setTimeout
body: <p>I know the output of the code but can anyone please tell me when setTimeout will be called please...</p>
  <pre><code>function delay(time) {
      
      return new Promise(function (resolve) {
          setTimeout(() =&gt; {
              resolve();            
          }, time);
      })
  }
  
  
  delay(3000).then(function () {
      console.log(&quot;run after 3000 seconds&quot;)
  })
  </code></pre>