I am currently learning async JavaScript, and I am confused about how to get the values retured by a promise my code:
let p  = Promise.resolve("Passed")
let x = p.then(msg=>msg).catch(msg=>msg)
setTimeout(()=>console.log(x), 2)
console.log(x)
Output:
Promise { <pending> }
Promise { 'Passed' }
How can I get the string "Passed" which is being returned by the .then function, and why the promise is pending even when the Promise is resolved? But when we console.log its value using a setTimeout function is gives its value, and How to get the "Passed" from Promise { 'Passed' }
 
     
    