Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is different from es6-Promise,when resolve a promise.below is the code and result #45

Open
vickygaogao opened this issue Jul 26, 2020 · 0 comments

Comments

@vickygaogao
Copy link

below is the code and result

code

    function fn1() {
        console.log("async1 start", 1);
        return new Promise((r) => {
          r(fn2());                                          // resolve a promise
        }).then(() => console.log("async1 end", 4));
      }

      function fn2() {
        console.log("async2", 2);
        return new Promise((r) => {
          r(123);
        });
      }

      setTimeout(() => {
        console.log("timeout", 8);
      }, 0);

      fn1();

      new Promise((r) => {
        console.log("promise", 3);
        r();
      })
        .then((d) => {
          console.log("promise2", 5);
        })
        .then((d) => {
          console.log("promise3", 6);
        })
        .then((d) => {
          console.log("promise4", 7);
        });

es6-Promise result
image

lie result
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant