New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added more helpful technique for accessing promise #1124
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
<pre> | ||
<code id="static-js">var promise1 = new Promise(function(resolve, reject) { | ||
setTimeout(resolve, 100, 'foo'); | ||
setTimeout(function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's weird to mix arrow functions and non-arrow functions, is there a reason you're doing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me know if I need to do any other changes. Thanks for your time. |
||
resolve('foo'); | ||
}, 300); | ||
}); | ||
|
||
promise1.then(function(value) { | ||
console.log(value); | ||
// expected output: "foo" | ||
}); | ||
|
||
console.log(promise1); | ||
// expected output: [object Promise] | ||
|
||
</code> | ||
</pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
setTimeout
like this, with a 3rd argument ('foo') - is IMHO rather rare.