Skip to content

Instantly share code, notes, and snippets.

@ms2sato
Last active May 12, 2016 04:59
Show Gist options
  • Save ms2sato/bdc681eba9736d4c9a6282682e8fa4a9 to your computer and use it in GitHub Desktop.
Save ms2sato/bdc681eba9736d4c9a6282682e8fa4a9 to your computer and use it in GitHub Desktop.
<html>
<script>
console.log("start");
var p = new Promise(function(resolve, reject) {
setTimeout(function(){
resolve();
}, 3000);
}).then(function(){
console.log("3000ミリ秒")
var next = 2000;
return new Promise(function(resolve, reject){
setTimeout(function(){
resolve(next + 3000);
}, next);
});
}).then(function(time){
console.log(time + "ミリ秒経った");
return new Promise(function(resolve, reject){
setTimeout(function(){
reject(new Error("rejectされた!"));
}, aaaaaa);
});
}).then(function(){
console.log("reject されたら呼ばれないはず")
}).catch(function(e){
console.log("reject キャッチ: " + e.message);
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment