await new Promise(resolve => setTimeout(resolve, 5000)); // 5 second wait
//or
(async () => {
await new Promise(resolve => setTimeout(resolve, 5000)); // 5 second wait
})();
If the value of the expression following the await operator is not a Promise, it's converted to a resolved Promise.
The await operator is used to wait for a Promise. It can only be used inside an async function within regular JavaScript code; however it can be used on its own with JavaScript modules.
const a = async () => {
await b();
c();
};