Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add creating promise in js
Browse files Browse the repository at this point in the history
  • Loading branch information
sicktastic committed May 13, 2016
1 parent 77e7a99 commit 0198904
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Binary file added promises/.creating_promise.js.swp
Binary file not shown.
18 changes: 18 additions & 0 deletions promises/creating_promise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// A Promise that returns a value
function theUltimateAnswer() {
return new Promise(function(resolve) {
setTimeout(function(){
var value = 42;
resolve(value);
}, 3000);
});
}

promise = theUltimateAnswer()
// Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}

promise
// Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}

promise
// Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: 42}})

0 comments on commit 0198904

Please sign in to comment.