DEV Community

Tahir Rafique
Tahir Rafique

Posted on

setTimeout in JavaScript.

console.log('hello 1');
console.log('hello 2');
console.log(function()
{console.log('hello 3, I have to wait for a time of 2 Second.')}
, 2000);
console.log('hello 4, i am printed Before hello 3')
Enter fullscreen mode Exit fullscreen mode

Details:
It's a very simple setTimeout in JavaScript, which is asynchronous code that gets put on the side stack and callback queue. In my code example, this asynchronous code runs after a delay of 2 seconds.

Top comments (0)