Node.js Interview Questions and
Answers 100% Correct
Now ES6 modules are incompatible with Node.js modules. This has to do with the way
modules are loaded differently between the two formats. If you use a compiler like
Babel, you can mix and match module formats.
Does Node.js operate in a single-threaded or multi-threaded fashion? - ANSWER-
Node.js operates on a single thread.
Does the fs module, used for file-based operations, offer the possibility for synchronous
or asynchronous reading and writing? - ANSWER-fs offers both synchronous and
asynchronous methods for reading from and writing to files.
How are objects that generate events called and which class from the events module
are they instances of? - ANSWER-These objects are called event emitters and are
instances of the EventEmitter class.
How does Node.js handle child threads? - ANSWER-Node.js, in its essence, is a single
thread process. It does not expose child threads and thread management methods to
the developer. Technically, Node.js does spawn child threads for certain tasks such as
asynchronous I/O, but these run behind the scenes and do not execute any application
JavaScript code, nor block the main event loop.
If threading support is desired in a Node.js application, there are tools available to
enable it, such as the ChildProcess module.
Rewrite promise-based Node.js applications to Async/Await - ANSWER-
What are async and await? - ANSWER-A function marked with the async keyword can
contain an await expression. The await expression pauses the execution of the function
and waits for the resolution of the passed Promise. It then resumes the function's
execution and returns the resolved value.
What are the benefits of using Node.js? - ANSWER-Following are main benefits of
using Node.js:
Aynchronous and Event Driven - All APIs of Node.js library are aynchronous that is non-
blocking. It essentially means a Node.js based server never waits for a API to return
data. Server moves to next API after calling it and a notification mechanism of Events of
Node.js helps server to get 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 server to respond in a non-bloking ways and makes
server highly scalable as opposed to traditional servers which create limited threads to
handle requests. Node.js uses a single threaded program and same program can
services much larger number of requests than traditional server like Apache HTTP
Server.
No Buffering - Node.js applications never buffer any data. These applications simply
output the data in chunks.
What are the key features of Node.js? - ANSWER-Let's look at some of the key features
of Node.js.
Asynchronous event driven IO helps concurrent request handling - All APIs of Node.js
are asynchronous. This feature means that if a Node receives a request for some
Input/Output operation, it will execute that operation in the background and continue
with the processing of other requests. Thus it will not wait for the response from the
previous requests.
Fast in Code execution - Node.js uses the V8 JavaScript Runtime engine, the one
which is used by Google Chrome. Node has a wrapper over the JavaScript engine
which makes the runtime engine much faster and hence processing of requests within
Node.js also become faster.
Single Threaded but Highly Scalable - Node.js uses a single thread model for event
looping. The response from these events may or may not reach the server immediately.
However, this does not block other operations. Thus making Node.js highly scalable.
Traditional servers create limited threads to handle requests while Node.js creates a
single thread that provides service to much larger numbers of such requests.
Node.js library uses JavaScript - This is another important aspect of Node.js from the
developer's point of view. The majority of developers are already well-versed in
JavaScript. Hence, development in Node.js becomes easier for a developer who knows
JavaScript.
There is an Active and vibrant community for the Node.js framework - The active
community always keeps the framework updated with the latest trends in the web
development.
No Buffering - Node.js applications never buffer any data. They simply output the data
in chunks.
What are the names of at least three of the most popular Node.js frameworks? -
ANSWER-Express, Koa, Hapi, Meteor, Sails, Loopback etc.
Answers 100% Correct
Now ES6 modules are incompatible with Node.js modules. This has to do with the way
modules are loaded differently between the two formats. If you use a compiler like
Babel, you can mix and match module formats.
Does Node.js operate in a single-threaded or multi-threaded fashion? - ANSWER-
Node.js operates on a single thread.
Does the fs module, used for file-based operations, offer the possibility for synchronous
or asynchronous reading and writing? - ANSWER-fs offers both synchronous and
asynchronous methods for reading from and writing to files.
How are objects that generate events called and which class from the events module
are they instances of? - ANSWER-These objects are called event emitters and are
instances of the EventEmitter class.
How does Node.js handle child threads? - ANSWER-Node.js, in its essence, is a single
thread process. It does not expose child threads and thread management methods to
the developer. Technically, Node.js does spawn child threads for certain tasks such as
asynchronous I/O, but these run behind the scenes and do not execute any application
JavaScript code, nor block the main event loop.
If threading support is desired in a Node.js application, there are tools available to
enable it, such as the ChildProcess module.
Rewrite promise-based Node.js applications to Async/Await - ANSWER-
What are async and await? - ANSWER-A function marked with the async keyword can
contain an await expression. The await expression pauses the execution of the function
and waits for the resolution of the passed Promise. It then resumes the function's
execution and returns the resolved value.
What are the benefits of using Node.js? - ANSWER-Following are main benefits of
using Node.js:
Aynchronous and Event Driven - All APIs of Node.js library are aynchronous that is non-
blocking. It essentially means a Node.js based server never waits for a API to return
data. Server moves to next API after calling it and a notification mechanism of Events of
Node.js helps server to get 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 server to respond in a non-bloking ways and makes
server highly scalable as opposed to traditional servers which create limited threads to
handle requests. Node.js uses a single threaded program and same program can
services much larger number of requests than traditional server like Apache HTTP
Server.
No Buffering - Node.js applications never buffer any data. These applications simply
output the data in chunks.
What are the key features of Node.js? - ANSWER-Let's look at some of the key features
of Node.js.
Asynchronous event driven IO helps concurrent request handling - All APIs of Node.js
are asynchronous. This feature means that if a Node receives a request for some
Input/Output operation, it will execute that operation in the background and continue
with the processing of other requests. Thus it will not wait for the response from the
previous requests.
Fast in Code execution - Node.js uses the V8 JavaScript Runtime engine, the one
which is used by Google Chrome. Node has a wrapper over the JavaScript engine
which makes the runtime engine much faster and hence processing of requests within
Node.js also become faster.
Single Threaded but Highly Scalable - Node.js uses a single thread model for event
looping. The response from these events may or may not reach the server immediately.
However, this does not block other operations. Thus making Node.js highly scalable.
Traditional servers create limited threads to handle requests while Node.js creates a
single thread that provides service to much larger numbers of such requests.
Node.js library uses JavaScript - This is another important aspect of Node.js from the
developer's point of view. The majority of developers are already well-versed in
JavaScript. Hence, development in Node.js becomes easier for a developer who knows
JavaScript.
There is an Active and vibrant community for the Node.js framework - The active
community always keeps the framework updated with the latest trends in the web
development.
No Buffering - Node.js applications never buffer any data. They simply output the data
in chunks.
What are the names of at least three of the most popular Node.js frameworks? -
ANSWER-Express, Koa, Hapi, Meteor, Sails, Loopback etc.