Node.js Interview Questions
A list of top frequently asked Node.js interview questions and answers are given below.
1) What is Node.js?
2) Is Node.js free to use?
Yes. It is released under MIT license and is free to use.
3) Is Node a single threaded application?
Yes. Node is a single threaded application with event looping.
4) What is the purpose of Node.js?
Node.js can be used for the following purposes:
5) What are the advantages of Node.js?
Following are the main advantages of Node.js:
6) What do you understand by the term I/O?
I/O stands for input and output. It will access anything outside of your application. It will be loaded into the machine memory to run the program, once the application is started.
7) How many types of API functions are available in Node.js?
There are two types of API functions in Node.js:
8) What is error-first callback?
Error-first callbacks are used to pass errors and data. If something goes wrong, the programmer has to check the first argument because it is always an error argument. Additional arguments are used to pass data.
9) What is an asynchronous API?
All the API's of Node.js library are asynchronous means non-blocking. A Node.js based server never waits for an API to return data. The Node.js server moves to next API after calling it and a notification mechanism of Events of Node.js provides response to the server for the previous API call.
10) How can you avoid callbacks?
To avoid callbacks, you can use any one of the following options:
11) What is a control flow function?
Control flow function is a generic piece of code that runs in between several asynchronous function calls.
12) How "Control Flow" controls the functions calls?
The control flow does the following job:
13) Is it possible to access DOM in Node?
No, it is not possible to access DOM in Node.
14) What types of tasks can be done asynchronously using the event loop?
15) What is REPL in Node.js?
REPL stands for Read Eval Print Loop. It specifies a computer environment like a window console or Unix/Linux shell where you can enter a command and the computer respond with an output.
REPL environment is incorporated with Node.js.
16) Explain the tasks of terms used in Node REPL.
Following are the terms used in REPL with their defined tasks:
Eval: It takes and evaluates the data structure.
Print: It is used to print the result.
Loop: It loops the above command until user press ctrl-c twice to terminate.
17) Is it possible to evaluate simple expressions using Node REPL?
Yes. You can evaluate simple expressions using Node REPL.
18) What is the use of underscore variable in REPL?
In REPL, the underscore variable is used to get the last result.
19) What is npm? What is the main functionality of npm?
npm stands for Node Package Manager. Following are the two main functionalities of npm:
20) What tools can be used to assure consistent style in Node.js?
Following is a list of tools that can be used developing code in teams, to enforce a given style guide and to catch common errors using static analysis.
21) What is the difference between operational and programmer errors?
Operational errors are not bugs, but create problems with system like request timeout or hardware failure. On the other hand, programmer errors are actual bugs.
22) What is the difference between global installation of dependencies and local installation of dependencies?