Promise的finally定义,为什么要加 isFunction(callback)) 这个判断,两个return的写法,有什么区别?
finally(callback) {
let promise = this;
let constructor = promise.constructor;
if (isFunction(callback)) {
return promise.then(value => constructor.resolve(callback()).then(() => value),
reason => constructor.resolve(callback()).then(() => { throw reason; }));
}
return promise.then(callback, callback);
}