美文网首页
13,Promise构造函数、then的理解

13,Promise构造函数、then的理解

作者: r8HZGEmq | 来源:发表于2019-11-18 19:13 被阅读0次

    深入理解,转至题10

    const promise = new Promise((resolve, reject) => {
      console.log(1)
      resolve()
      console.log(2)
    })
    
    promise.then(() => {
      console.log(3)
    })
    
    console.log(4)
    执行结果是:1243
    promise构造函数是同步执行的,then方法是异步执行的
    

    相关文章

      网友评论

          本文标题:13,Promise构造函数、then的理解

          本文链接:https://www.haomeiwen.com/subject/lhnbictx.html