The difference of promise between chrome and firefox

let p1 = new Promise(resolve => {
    resolve("promise1 resolved");
})    
        
var p2 = p1.then(function(res){});

console.log("promise2: ",p2);

chrome: {} shows pending, while [[PromiseStatus]] below shows resolved
clipboard.png

firefox :
clipboard.png

p2 is the initial state of Promise, returned by then () is pending, and there is no resolve, that should be kept in the state of pending all the time. Firefox"s performance is correct. I don"t know why chrome shows a status of resolved?

Mar.24,2021

you should know that the objects printed in the chrome console are all references , which are evaluated by references only when you expand them.

at the moment when you console.log ('promise2:', p2) executes, the value of [[PromiseStatus]] is indeed pending', but when you click and click to expand, p2 has already become a resolve state, so of course you can't see the intermediate state of 'pending'. You can add a debugger statement after console.log (' promise2:', p2) . You can see the status of p2 on the console.

instantaneous status:
clipboard.png


returns a value, the promise returned by then gets resolved with the returned value as its value;
throws an error, the promise returned by then gets rejected with the thrown error as its value;
returns an already resolved promise, the promise returned by then gets resolved with that promise's value as its value;
returns an already rejected promise, the promise returned by then gets rejected with that promise's value as its value.
returns another pending promise object, the resolution/rejection of the promise returned by then will be subsequent to the resolution/rejection of the promise returned by the handler. Also, the value of the promise returned by then will be the same as the value of the promise returned by the handler.
from here: https://developer.mozilla.org.
Menu