About promise and setTimeout

var p1 = new Promise(function (resolve, reject) {
    setTimeout(function(){
        resolve(1);
        console.log("p1");
    },5000)
});

var p2 = new Promise(function (resolve, reject) {
      resolve(p1);
}).then(function(data){
    console.log(data);
    console.log("p2");
})

Why does the result be p1percent = > 1percent = > p2 instead of 1percent = > p2percent = > p1?

Apr.05,2021

p2 is determined by p1. After 5000ms, pi is changed to resolved, p2 is directly changed to resolved, and then then is executed

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b55c-2c27a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b55c-2c27a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?