Home  »  CodeProgrammingSnippetsTechnology   »   How to Use setTimeout Function in Vanilla JavaScript

How to Use setTimeout Function in Vanilla JavaScript

Posted: August 3, 2022 | by Michael Bright

Vanilla JavaScript setTimeout code snippet to delay a function call.

setTimeout(function(){
    alert("Hello after 2 seconds"); 
}, 2000); // wait 2 seconds

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.