Following are some of the Commonly asked Node.js interview questions and answers
Explain what is Node.js ?
- Node.js is a server framework.It has following features:
- Node.js is an open source server frameworkNode.js allows running JavaScript on the server.
- Node.js provides event-driven,non-blocking I/O programming.It is based on the Google Chrome’s V8 Engine.
Which applications are more suitable to be developed using Node.js?
Following applications will see improvement in performance when developed using Node.js :
- web applications
- web tools such as task runners
- I/O based applications
- Streaming applications
- Network applications
What is Asynchronous programming in Node.js?
In normal synchronous programming code is executed sequentially.This means that the first block of code should be executed before next bloxk ofcode could be executed.This means that the first block of code blocks the next block of code.In asynchronous programming ,which is used in Node.js ,the code to execute does not depend on the previous block of code.In other words there is no dependency on the sequence of code.This results in applications which executes faster.
What is a callback?
A callback is a function which executes when a task is completed.This prevents blocking operations.You call a task and define a callback for this task.The callback is executed after the task executes.This is how asynchronous applications ,developed in Node.js,works.
What is a Promise? Promise is a object which stands for the result of a callback.You register a callback using the promise method then()
asyncFunction(argumen1, argumen2).then(result => {//});
What is an Event Loop?
Node.js applications uses the concepts of loops.This means that you register a callback for an event.When the event is executed the callback is pushed on the event loop.The event loop can consist of multiple callbacks.Event loop executes callbacks in a FIFO manner.
How many threads can Event Loop utilize?
Event Loop runs under a single thread.But the callbacks can run in different background threads.
How Node.js improves the performance of application?
Node.js uses a single non-blocking thread.This means that thread runs time consuming tasks as I/O asynchronously.So instead of creating a new thread for every request ,Node.js uses the same thread for every request.This improves the performance of the application.
What is npm?
NPM is Node Package Manager. NPM is a repository of node.js pcakges.
What is ExpressJS?
ExpressJS is a Node.js web framwork for developing web and mobile applications.
What is MEAN stack?
MEAN is a group of technolgies used for developing web application.Following tehnologies are part of the MEAN stack:
- Node.js Javascript based server side framework
- Express Framework to develop web applications
- MongoDB NoSQL database
- AngularJS JavaScript framework to develop front end of web applications.