Frequently asked Top 60+ Node.JS interview questions and best answers for freshers and 2-5 year experienced web developers.
Node.js was developed in 2009 by Ryan Dahl.
4) What are the features of Node.js?
Below are the features of Node.js –
- Very Fast
- Event driven and Asynchronous
- Single Threaded but highly Scalable
5) Explain REPL in Node.js?
REPL stands for Read Eval Print Loop. Node.js comes with bundled REPL environment which performs the following desired tasks –
6) Explain variables in Node.js?
Variables are used to store values and print later like any conventional scripts. If “var” keyword is used then value is stored in variable. You can print the value in the variable using - console.log().
> a = 30
> var b = 50
> a + b
7) What is the latest version of Node.js available?
Latest version of Node.js is - v0.10.36.
8) List out some REPL commands in Node.js?
Below are the list of REPL commands –
- Ctrl + c - For terminating the current command.
- Ctrl + c twice – For terminating REPL.
- Ctrl + d - For terminating REPL.
- Tab Keys - list of all the current commands.
- .break - exit from multiline expression.
- .save with filename - save REPL session to a file.
9) Mention the command to stop REPL in Node.js?
Command - ctrl + c twice is used to stop REPL.
10) Explain NPM in Node.js?
NPM stands for Node Package Manager (npm) and there are two functionalities which NPM takes care of mainly and they are –
- Online repositories for node.js modules or packages, which can be searched on search.nodejs.org
- Dependency Management, Version Management and command line utility for installing Node.js packages.
11) Mention command to verify the NPM version in Node.js?
Below command can be used to verify the NPM version –
$ npm --version
12) How you can update NPM to new version in Node.js?
Below commands can be used for updating NPM to new version –
$ sudo npm install npm -g
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
13) Explain callback in Node.js?
Callback is called once the asynchronous operation has been completed. Node.js heavily uses callbacks and all API’s of Node.js are written to support callbacks.
14) How Node.js can be made more scalable?
Node.js works good for I/O bound and not CPU bound work. For instance if there is a function to read a file, file reading will be started during that instruction and then it moves onto next instruction and once the I/O is done or completed it will call the callback function. So there will not be any blocking.
15) Explain global installation of dependencies?
Globally installed dependencies or packages are stored in <user-directory>/npm directory and these dependencies can be used in Command Line Interface function of any node.js.