私は期待どおり1 2 3
の代わりに2 1 3
を次のように印刷するのはなぜですか?ES2015 Promiseチェーン - なぜpromisified関数はすぐに実行されますか?
(function() {
return new Promise(function(resolve) {
document.write('2');
resolve();
})
.then(log('1')); // I was expecting this `log` function invocation to run first
}());
function log(message) {
document.write(message);
return function() {
document.write('3');
}
}
私はクローム49.0.2623.112 mを使用しています。
executor関数が最初に実行されます。表示されている結果は、コードごとに正しいです。 –
なぜ '2 1 3'が正しくないと思いますか? – ach