Best Online Tutorials

SQL Tutorial

Free SQL Tutorial

SQL Interview Questions

SQL Practice Questions

SQL Tips & Tricks

SQL Errors

SQL Books

Angular Tutorial

Free Angular Tutorial

Angular Interview Questions

Angular Practice Questions

Angular Tips & Tricks

Angular Errors

Angular Books

Node.js Tutorial

Free Node.js Tutorial

Node.js Interview Questions

Node.js Practice Questions

Node.js Tips & Tricks

Node.js Errors

Node.js Books

React.js Tutorial

Free React.js Tutorial

React.js Interview Questions

React.js Practice Questions

React.js Tips & Tricks

React.js Errors

React.js Books

SSIS Tutorial

Free SSIS Tutorial

SSIS Interview Questions

SSIS Practice Questions

SSIS Tips & Tricks

SSIS Errors

SSIS Books

SEO Tutorial

Free SEO Tutorial

SEO Interview Questions

SEO Practice Questions

SEO Tips & Tricks

SEO Errors

SEO Books

Javascript Tutorial

Free Javascript Tutorial

Javascript Interview Questions

Javascript Practice Questions

Javascript Tips & Tricks

Javascript Errors

Javascript Books

MongoDB Tutorial

Free MongoDB Tutorial

MongoDB Interview Questions

MongoDB Practice Questions

MongoDB Tips & Tricks

MongoDB Errors

MongoDB Books

Next.js Tutorial

Free Next.js Tutorial

Next.js Interview Questions

Next.js Practice Questions

Next.js Tips & Tricks

Next.js Errors

Next.js Books

Node.js Interview Questions and Answers | Part 2 

Pooja Goel  |   Dec 27, 2019  |  Views: 106
pictures

Description:

11. Is Node Js Single-threaded ? If yes Why?


Yes, Node.js is a Single threaded.
It has a single thread process which works on the non-blocking event loop callbacks.
We cann't create it multi-threaded.

If a request comes, it is first sent to the event queue, and executes it asynchronously, when an event is completed, another event which was passed as callback is then executed.


12. Explain callback in Node.js?


Callbacks are a normal function which is passed as a parameter to any asynchronous functions operation's completion.
It is invoked inside the another functions in which its been passed.
It's just a convention and an asynchronous equivalent for a function.
Node.js works on callbacks chain to maintain synchronization of asynchronous operations.
Due to heavy use of callbacks, there may also have callback Hell in Node.js.
Callbacks are used to write Non-Blocking Codes.


13.  For what require() is used in Node Js ?


To import the module in your application page:

cont xyz = require('module_name');


14.  What is v8 engine in node JS?


V8 is a JavaScript runtime engine built at the google development center, in Germany.
It is open source and written in C++. 
It is used for both client side (Google Chrome) and server side (node.js) JavaScript applications. 
V8 was first designed to increase the performance of the JavaScript execution inside the web browsers.


15.  Explain module.exports in Node Js ?


Node.js application is considered as a main module and a global object called module is available.
If we create our own module and want to acess globally in our all pages within the sam eapplication, we have to register our custom module inside the main module object with the help of module.exports.

const getName = () => {
  return 'DritalConnect';
};

module.exports.getName = getName;

16.  Which is the first argument typically passed to a Node.js callback handler ?


Error : err argument   (Follows error first concept)


17.  What are the functionalities of NPM in Node.js


To initialize the package.json file
To manage package.json file
To update npm packages
To start/build/test/debug... and noe.js application using commands


18.  What are events in Node.js?


Events are the actions, by which we can handle our callback methods synchronously.

Events can be created, fired, and listen for any action name.

Objects in Node.js also emit events which are the instances of events.EventEmitter.

Example:
fs.readStream emits an event when a file is opened.
var fs = require('fs');
var rs = fs.createReadStream('./sample.txt');
rs.on('open', function () {
  console.log('File is open');
});


19.  Explain event loop in Node Js ?


If a request comes, it is first sent to the event queue, and executes it asynchronously, when an event is completed, another event which was passed as callback is then executed.


20. How to create a simple server in Node js that returns Hello DritalConnect ?


Create a JavaScript file named test.js and write below code

console.log("Hello DritalConnect !!")

After creating the file, open a command prompt (cmd.exe) and run command

node test.js

Note:  test.js file path should be correctly defined., or open the cmd at the same directory the file exists.

You will see, the output "Hello DritalConnect !!" in command prompt.



Comments:
Content Contributor
Pooja Goel

Pooja Goel

Sr. Software developer at Damco Solutions Pvt. Ltd.  |   Noida, Uttar Pradesh, India

I am a sr. software developer working on technologies like SQL, SSIS, SSRS, DB2,Tableau, ASP.NET having 7 years of experience.


Read related articles

Node.js Interview Questions and Answers | Part 5

Pooja Goel  |   Dec 30, 2019  |  Views: 207

Node.js Interview Questions and Answers | Part 4

Pooja Goel  |   Dec 30, 2019  |  Views: 260

Node.js Interview Questions and Answers | Part 3

Pooja Goel  |   Dec 30, 2019  |  Views: 151

Node.js Interview Questions and Answers | Part 2

Pooja Goel  |   Dec 27, 2019  |  Views: 107

Node.js Interview Questions and Answers | Part 1

Pooja Goel  |   Dec 27, 2019  |  Views: 300

Want to sell your software ?-

If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.

  • Sell ERP
  • Sell Website Clones
  • Sell App Clones
  • Sell Readymade Portals
  • Sell Readymade Websites
  • Sell Mobile Apps
  • Sell Window Apps

Clients will find it using our advanced search filter and will contact you directly.

No any charge for the product lsiting.

Do you own a Company ?+

Property.sale

Buy or Sell Commercial Property+

Are you a freelancer ?+

Looking for a job ?+

Are you a Service Provider ?+

Are you a blogger ?+

Do you own an IT Institute ?+


Property.sale