new Promise(function (resolve, reject) {
resolve(11);
}).then(function(data){console.log(data)});
var aa = function(){
console.log(111)
return 1;
}
Promise.resolve(aa).then(function(data){console.log(data)})
Promise.reject(new Error('some awful error'));
高級錯誤#3:promises vs promise工廠
function executeSequentially(promiseFactories) {
var result = Promise.resolve();
promiseFactories.forEach(function (promiseFactory) {
result = result.then(promiseFactory);
});
return result;
}