How to wait for function call in Javascript without calling it directly
you can use Promises. In your case, you can modify your First and Second functions to return Promises. This way, you can await the completion of Second without having to call it directly. like this function First() { console.log('First is called'); return new Promise(resolve => { setTimeout(() => { Second(); resolve(); // Resolve the promise