GithubHelp home page GithubHelp logo

你真的懂Promise吗 about blog HOT 4 OPEN

ljianshu avatar ljianshu commented on May 25, 2024
你真的懂Promise吗

from blog.

Comments (4)

xyj1020 avatar xyj1020 commented on May 25, 2024 3

from blog.

xyj1020 avatar xyj1020 commented on May 25, 2024

博主,你好,我对这句话的后半句有点疑问 “如果参数中的任何一个promise为reject的话,则整个Promise.all调用会立即终止,并返回一个reject的新的 Promise 对象” , 这里的reject指的是什么呀?是新Promise的状态吗?如果是新promise的状态的话,不应该是resolve吗?
1586248392347

from blog.

liujun789 avatar liujun789 commented on May 25, 2024

1.image
我实际运行得到的结果跟你所说的相反,即promise是失败状态,则await也会接收其返回结果,await下面的代码也会执行
如图:
image

2.蓝框的内容,写的不全吧,当是错误状态,没有catch去捕获会报错吧

from blog.

yyyyyyuyu avatar yyyyyyuyu commented on May 25, 2024

博主,你好,我对这句话的后半句有点疑问 “如果参数中的任何一个promise为reject的话,则整个Promise.all调用会立即终止,并返回一个reject的新的 Promise 对象” , 这里的reject指的是什么呀?是新Promise的状态吗?如果是新promise的状态的话,不应该是resolve吗?
1586248392347

image
是新Promise的状态 不是reject的话,后面怎么会进入catch函数呢,你这样写p4只是等于了后面.catch 新返回的Promise对象,而不是Prmoise.all 返回的新Promise对象

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.