async and await
async function test() { //Invoking an async function returns a promise. const promise1 = test2(); console.log(promise1); const output = await promise1.catch((error) => console.log(error)); console.log("Output = " + output); const promise2 = test3(); console.log(promise2); const output2 = await promise2.catch((error) => console.log(error)); console.log("Output = " + output2); //The following commented code is incorrect as the function test3 doesn't return a promise and also not an async //function. //The await operator is used to wait for a Promise. It can only be used inside an async function. //If the value is not a Promise, it converts the value to a resolved Promise, and waits for it. //const output3 = await test4().catch((error) => console.log(error)); const output3 = await test4(); console.log("Output = " + output3); const promise3 = test5(); console.log(promise3); const output4 = await p...