Skip to content

Instantly share code, notes, and snippets.

@joepie91
Last active September 18, 2015 22:01
Show Gist options
  • Save joepie91/48042173a6c9c4065399 to your computer and use it in GitHub Desktop.
Save joepie91/48042173a6c9c4065399 to your computer and use it in GitHub Desktop.
Testing Promises/A+ compliance
var pr = new Promise(function(resolve, reject) {
resolve("a");
})
pr.then(function(val) {
console.log(".then triggered");
})
console.log("after defining .then");
@joepie91
Copy link
Author

Correct output, for a Promises/A+ compliant implementation:

after defining .then
.then triggered

If the order is different, then the implementation is not A+ compliant, as the .then handlers are not guaranteed to be executed asynchronously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment