Last active
May 12, 2016 04:59
-
-
Save ms2sato/bdc681eba9736d4c9a6282682e8fa4a9 to your computer and use it in GitHub Desktop.
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
<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