首页 > 代码库 > Promise

Promise

function sayhello() {
    return Promise.resolve(‘我是返回的值/将要传递给then‘).then(function(hello) {
        console.log(hello);
    });
}
function helloworld() {
    sayhello();
    console.log(‘world‘);
}
helloworld();

输出

> "world"
> "我是返回的值/将要传递给then"

Promise