could someone please explain this code in depth?
const promiseFactory = () =>
new Promise(resolve => setTimeout(() => resolve(1), 5000));
If I call this with the following:
const consumer = async() => {
promiseFactory().then(s => console.log(s));
console.log("next step");
}
will output "next step" and after 5seconds but if I call it with the following,
const consumer = async() => {
const val = await promiseFactory();
console.log(val);
console.log("next step");
}
will output 1 and then "next step" So in the end promises and async/await are not just a syntax difference?