编辑代码

let func = function() {
    return new Promise((resolve, reject) => {
        resolve('返回值');
    });
};

let cb = function() {
    return '新的值';
}

func().then(function(){
    return cb();
}).then(resp => {
    console.warn(resp); //新的值
    console.warn('1 =========<');
})
// func.then() 传入了函数,返回值为'新的值'
func().then(function () {
    cb();
}).then(resp => {
    console.warn(resp); // undefined
    console.warn('2 =========<');
});
// func.then() 传入了函数,没有返回值,默认'undefined'
func().then(cb()).then(resp => {
    console.warn(resp); // 返回值
    console.warn('3 =========<');
});
// func.then() 传入不是函数,忽略该then方法,后面值传的func的返回值'返回值'
func().then(cb).then(resp => {
    console.warn(resp); // 新的值
    console.warn('4 =========<');
});
// func.then() 传入cb函数,cb返回了‘新的值’