InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
What is test pyramid? Explain with an example? |
|
Answer» A test pyramid is a metaphor that helps the grouping of software tests in a bunch of different granularity. Unit testing pyramid number of tests GETS easily fitted. For INSTANCE, unit testing, component testing, integration testing, system testing, end-to-end testing, UI testing, and OTHERS. The primary EXAMPLE of it is creating a unit test which will be the fastest and reliable. |
|
| 52. |
List some events that fired by streams in Node JS? |
| Answer» | |
| 53. |
What is a Reactor Pattern in Node.js? |
|
Answer» Reactor PATTERN is used for non-blocking Input/Output OPERATIONS in the Node.js. This pattern provides a handler that is associated with I/O operations. When I/O requests are generated, they get submitted to a demultiplexer, which handles concurrency in non-blocking I/O mode and collects requests in the form of an event and queues the events. Note: This Node js interview questions have been created by Node.js Experts. It shall HELP you to answer some of the most frequently ASKED questions during a job interview. |
|
| 54. |
Define an error-first callback? |
|
Answer» ERROR-first callbacks are generally USED to pass ERRORS as well as data. It is important to pass the error as the first parameter, and then you must check if SOMETHING WENT wrong. There are additional arguments that are used to pass data. |
|
| 55. |
What is the timing features of Node.js? Explain some Timers modules? |
|
Answer» The timing feature of node.js CONTAINS all the necessary functions that are required to execute code after any specific period. As it is built on the V8 JavaScript ENGINE of Google Chrome, hence its library permits the FAST execution of code. Timers also provide a number of ways for managing schedules. They don't need to be imported as all the METHODS are easily available for the browser. Some modules are –
|
|
| 56. |
What are the difference between setTimeout() and clearTimeout()? |
|
Answer» setTimeout() : It can be used to schedule CODE EXECUTION after a designated amount of milliseconds. function myFunc(arg) { clearTimeout() : It can be used to CANCEL timeout which are set by setTimeout(). console.log('before IMMEDIATE'); |
|
| 57. |
How we can open a file in Node JS? |
|
Answer» OPEN() FUNCTION is used to opens a file by passing a file name. Syntax : fs.open(path, flags[mode], callback) Parameters
var fs = require("fs"); // ASYNCHRONOUS - Open a File |
|
| 58. |
What is Piping in Node JS? |
|
Answer» A pipe is a function that reads the data from a readable STREAM once it is available and writes it in the destination WRITABLE stream. It performs all the REASONABLE things including the errors, files in CASE any one side falls apart. In due case, piping redirections any readable stream to a writable stream. |
|
| 59. |
What is a buffer and stream in Node.js? |
|
Answer» Buffer It is a global class that can be accessed in an application without importing the buffer MODULE. It can be constructed in a variety of ways like VAR buf = new Buffer(5); Use of a buffer in Node JSBuffer is used to dealing with TCP streams, reading, and writing data to the filesystem in the Node.js server, which are PURELY binary teams of data. It is designed in a way that is easy to manage, faster and has an API designed for binary data, which makes it the perfect choice for handling streams of data. Streamthese are the objects that allow the developers to read the data from the source or can write the data to the destination in an endless manner. They usually have problems with the large data. With a stream, there is no need to wait for the whole resource to load. There are DIFFERENT types of Stream:
|
|
| 60. |
How do you update NPM to a new version in Node.js? |
|
Answer» EXAMPLE $ sudo npm install npm -G |
|
| 61. |
How we can secure HTTP cookies against XSS attacks? |
|
Answer» we have to set flags on the set-cookie HTTP header:
After this it will lokk like this : Set-Cookie: sid=; HttpOnly Point to be noted: Make SURE that you GO through this twice as this is the FAVORITE node js interview QUESTIONS for fresher and experienced as WELL. |
|
| 62. |
What do you understand by middleware? How can you use middleware in Node JS? |
|
Answer» Middleware functions are those functions having access to the request object (req), the response object (RES), and also the next FUNCTION in an application's request-response cycle. The following function is BASICALLY a function in the Express router, when invoked, executes the middleware which is succeeding in the current middleware. Middlewares can perform the following TASKS:
|
|
| 63. |
What is chaining in Node.js? |
|
Answer» This is a MECHANISM by which the output of one stream is CONNECTED to the output of another stream y creating a long chain of MULTIPLE stream OPERATIONS. |
|
| 64. |
How to get a user's IP address in node js? |
|
Answer» You can USE req.connection.remoteAddress to a USER's IP ADDRESS in node js. |
|
| 65. |
How will you debug an application in Node.js? |
|
Answer» The easiest way to debug an application on Node.js is through Node-Inspector. You can use it from any BROWSER SUPPORTING WebSockets. It helps multiple WAYS of debugging LIKE a profiler, livecoding, breakpoints, etc. Here's how to use node-inspector:
|
|
| 66. |
What are the different HTTP methods in Node.js? |
|
Answer» There are three HTTP methods in NodeJS. They are:
|
|
| 67. |
Why are promises better than callbacks? |
|
Answer» Here are some of the reasons why promises are better than callbacks:
|
|
| 68. |
How is observable different from promise? |
||||||||||
Answer»
Note: This node js INTERVIEW questions have been created by seasoned Node.js experts. It SHALL help you to answer some of the most frequently asked questions during a job interview. |
|||||||||||