Skip to content

Instantly share code, notes, and snippets.

@uangsl
Created March 12, 2017 06:12
Show Gist options
  • Select an option

  • Save uangsl/7ad05c6fc6822d6796398c648540b9f9 to your computer and use it in GitHub Desktop.

Select an option

Save uangsl/7ad05c6fc6822d6796398c648540b9f9 to your computer and use it in GitHub Desktop.
javascript Promise
new Promise(function(resolve, reject){
setTimeout(function(){
console.log("resolve", 1);
resolve("result");
}, 2000);
}).then(function(v){
return new Promise(function(resolve, reject) {
console.log("then", 2);
setTimeout(function(){
console.log("then", 3);
//resolve(v);
}, 2000);
});
}).then(function(v){
console.log("then then", 4);
console.log("then then", v);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment