Skip to content

Commit 5fa89c0

Browse files
committed
promise
1 parent a607b9f commit 5fa89c0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

promise.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//promise is an object
2+
//so we will make a new instance
3+
const promiseOne = new Promise(function(resolve , reject){
4+
//Do an async task , DB calls , crptograpgy , network
5+
setTimeout(function(){
6+
console.log('Async task is complete');
7+
resolve();
8+
}, 1000);
9+
});
10+
//resolve is linked with then but to connect then and resolve we need to call a function called resolve
11+
promiseOne.then(function(){
12+
console.log("Promise consumed");
13+
})

0 commit comments

Comments
 (0)