1.

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”); });I have been asked this question in an online interview.I'm obligated to ask this question of Asynchronous I/O with Rhino in division Server-Side and Client-Side Scripting of JavaScript

Answer»

Right CHOICE is (a) setTimeout(function() { console.log(“Hello WORLD”); }, 1000);

To explain I would say: 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.



Discussion

No Comment Found

Related InterviewSolutions