SOURCE

function getRandom() {
    return new Promise((resolve, reject) => {
        const random = Math.random() * 10;
        if (random > 5) {
            resolve(random);
        } else {
            reject("错误")
        }
    })
}
getRandom().catch(err => {
    console.log(err)
}).then(res => {
    console.log(res)
})

console 命令行工具 X clear

                    
>
console