NodeJS Interview Questions and Answers
Question - 71 : - What are event listeners?
Answer - 71 : -
Events that are emitted by event emitters have to listen in order to continue the asynchronous execution of the threads. These objects that listen to the emitted events are known as listeners.
Question - 72 : - What are event emitters in NodeJS?
Answer - 72 : -
Objects in NodeJS will have to trigger events in order to maintain the asynchronous execution of the core API used. These objects that emit events are known as Event Emitters.
Question - 73 : - What are the types of versions available?
Answer - 73 : -
Patch_Version, Minor_Version, Major_Version.
Explore Node.JS Sample Resumes Download & Edit, Get Noticed by Top Employers!
Question - 74 : - What is the use of the Nodemailer module.
Answer - 74 : -
It is not included in the default modules list, it has to be installed using npm.
Var nodemailer = require(‘nodemailer’);
Question - 75 : - How does the URL module work?
Answer - 75 : -
This module helps URL to parse it into host, pathname, search, query, etc.
Example:
var url = require('url');
var adr = 'https://mindmajix.com/?s=node+js+training';
var q = url.parse(adr, true);
console.log(q.host); //returns 'mindmajix.com'
console.log(q.search); //returns '?s=node+js+training'
Question - 76 : - What is the cluster?
Answer - 76 : -
Cluster is a process to handle thread execution load while working with multi-core systems.
Question - 77 : - What is an error-first callback in Node JS?
Answer - 77 : -
In order to check for the proper working of the code, we need to verify error-free execution. In this regard, error-first callbacks are used, which will send error first, followed by related data to the error.
Question - 78 : - Commands to work with the file from the local database.
Answer - 78 : -
Var fs = require(‘fs’);
Read: fs.readFile();
Create:
fs.appendFile();
fs.open();
fs.writeFile();
Write: fs. writeFile();
Delete: fs.unlink();
Rename: fs.rename();
Update:
fs.appendFile()
fs.writeFile()
Question - 79 : - What is REPL?
Answer - 79 : -
REPL - Read, Eval, Print, Loop.
It is an environment for input commands to perform REPL tasks. Each of the tasks is associated with its respective operations.
Question - 80 : - What are the attributes of package.json
Answer - 80 : -
Name, version, description, homepage, author, contributors, dependencies − list of dependencies, repository − repository type and URL of the package, the main − entry point of the package, keywords.