What is the code to print hello one second from now?
A
setTimeout(function() { console.log(“Hello World”); }, 1000);
B
setTimeout(function() { 1000, console.log(“Hello World”); });
C
setTimeout(function(1000) { console.log(“Hello World”); });
D
setTimeout(function() { console.log(“Hello World”); });
Correct Answer: setTimeout(function() { console.log(“Hello World”); }, 1000);
SetTimeout function is used to hold the execution of the code with the required amount of time. The argument of the setTimeout includes the function which is to be executed followed by the time after which the code is to be executed.