NodeJS Questions
Warm up for your NodeJS interview with most asked questions and answers for junior, mid, and senior roles.
What are the key features of Node.js?
Show AnswerHide Answer
Asynchronous and Event Driven − All APIs of Node.js library are asynchronous, that is, non-blocking. It essentially means a Node.js based server never waits for an API to return data. The server moves to the next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response from the previous API call.
Very Fast − Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution.
Single Threaded but Highly Scalable − Node.js uses a single threaded model with event looping. Event mechanism helps the server to respond in a non-blocking way and makes the server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and the same program can provide service to a much larger number of requests than traditional servers like Apache HTTP Server.
No Buffering − Node.js applications never buffer any data. These applications simply output the data in chunks.
License − Node.js is released under the MIT license.
What is meant by event-driven programming in Node.js?
Show AnswerHide Answer
Node. js uses event driven programming. It means as soon as Node starts its server, it simply initiates its variables, declares functions and then simply waits for event to occur.
What is JIT and how is it related to Node.js?
Show AnswerHide Answer
Virtual machine of Nodejs has JIT compilation which improves the execution speed of the code. The virtual machine takes the source code and converts to machine code in runtime.
By this, the hot functions which are called very often are compiled to machine code and, hence increasing speed.
What is Libuv?
Show AnswerHide Answer
Libuv is a C library that provides a high-level API for asynchronous I/O. It is used to implement the event loop for Node.js.
What is an event loop in Node.js?
Show AnswerHide Answer
The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.