What is the command to run the node programs?
a) node(program.js)
b) program.js
c) node program.js
d) node.program.js
Explanation: The node programs can be run with the command:node program.js. The command can be written more simply like node program.
What is the alternative command used in Node for load()?
a) store()
b) module()
c) log()
d) require()
Explanation: require() is used for including other javascript files. Use require() instead of load(). It loads and executes (only once) the named module, returning an object that contains its exported symbols.
What is the command used for debugging output in Node?
a) print();
b) console.log(…);
c) debug(…);
d) execute(…);
Explanation: Console.log() prints the content in the argument on to the output screen. Node defines console.log() for debugging output like browsers do.
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”); });
Explanation: 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.
Among the below given functions, Node supports which of the following client-side timer functions?
a) getInterval()
b) Interval()
c) clearTime()
d) clearTimeout()
Explanation: Client-side timer functions are used to perform applications based on time constraints. Node supports the client-side timer functions set setTimeout(), setInterval(), clearTimeout(), and clearInterval().
The necessary globals of a node are defined under which namespace?
a) Variables
b) system
c) process
d) using
Explanation: The process object is a global that provides information about, and control over, the current Node.js process. Node defines other important globals under the process namespace.