Returns a promise that resolves after a specified number of milliseconds. This is useful for delaying actions in asynchronous code.
The number of milliseconds to wait before resolving.
A promise that resolves after the given ms.
ms
await wait(2000); // Waits for 2 seconds before continuingconsole.log("This will print after 2 seconds"); Copy
await wait(2000); // Waits for 2 seconds before continuingconsole.log("This will print after 2 seconds");
Returns a promise that resolves after a specified number of milliseconds. This is useful for delaying actions in asynchronous code.