@heyrohit/promise-2.js
Nodejs

No description

I built🔨
THIS
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function getPromise() {
  const taskPromise = new Promise((resolve, reject) => {
    console.log("task started.");
    
    setTimeout(() => {
      console.log("done after 100ms.");
      resolve();
    }, 100);
  });
  
  return taskPromise;
}

const taskPromise = () => getPromise();

console.log("**Some other work before promise**");

// Now when taskPromise function is invoked, executor will be executed
taskPromise();
node v9.7.1 linux/amd64