Last active
August 29, 2015 13:59
-
-
Save getify/10518012 to your computer and use it in GitHub Desktop.
new JS employment quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Without running this code, state what the order of printed numbers will be. | |
console.log("1"); | |
(new Promise(function(resolve){ | |
console.log("2"); | |
resolve(); | |
console.log("3"); | |
})) | |
.then(function(){ | |
console.log("4"); | |
var p = new Promise(function(resolve){ | |
console.log("5"); | |
resolve(); | |
console.log("6"); | |
}); | |
console.log("7"); | |
return p; | |
}) | |
.then(function(){ | |
console.log("8"); | |
}); | |
console.log("9"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
console.log("2");
resolve();
console.log("3");
Running code after resolving a promise is super odd.