javascript - promise scheduling issues
阿神
阿神 2017-07-05 10:54:30
0
1
868
var p3 = new Promise( (resolve, reject) => { resolve('B') }) var p1 = new Promise( (resolve, reject) => { resolve(p3) }) p2 = new Promise( (resolve, reject) => { resolve('A') }) p1.then(v => console.log(v)) p2.then(v => console.log(v))

node is inconsistent with the browser operation. It is normal to understand that p1 resolves a promise internally and is not synchronous, so it is obviously later than p2.

阿神
阿神

闭关修行中......

reply all (1)
阿神

Whether it is outputting A B or B A, it is correct. This isasynchronous. None of our operations can depend on the return order of previous operations.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!