The window object represents an open window in a browser.
The window object has a built-in method called setTimeout.
This method will execute a callback function (or evaluate an expression) after a specified number of milliseconds.
Here is an example using a Named Function.

function myCallbackFunction() { 
window.setTimeout(myCallbackFunction, 1000);

Here is the same code using an Anonymous Function.

window.setTimeout(function() { 
}, 1000);

Using Async

async function myAsyncFunction() { 
   const myPromise = new Promise((resolve, reject) => {
      setTimeout( () => resolve("Return This String") , 1000)

   const theResult = await myPromise;


© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext