不明白知道代码promise.reject为什么会执行呢?

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        Promise.reject().then(() => {
            console.log('13');
        }, () => {
            console.log('6');
        })

        new Promise((resolve) => {
            console.log('7');
            resolve();
        }).then(() => {
            console.log('8')
        })
    </script>
</body>

</html>

执行结果是7,6,8 。
不明白为什么Promise.reject会执行呢?

阅读 1k
1 个回答

.then(f, g) 相当于 .then(f).catch(g)

图片.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题