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 11 

Prashant Surya  |   Jan 7, 2020  |  Views: 113
pictures

Description:

1. Differentiate between readFile vs createReadStream in Node.js


readFile - 
It reads the file and returns the complete data at one time, when it completes the full reading of the file, till the time it saves the whole data in its memory.

It needs more size of memory compared to another one.

In this case user have to wait until the completions of full reading task.

It sends data in delay.

createReadStream - 
It also reads the file, but it returns the data in chunks rather than returning all at one time.

It takes less size of memory compared to first one.

In this case users get the steaming data, so user don't have to wait for long.

It sends data faster as it sent out in chunks.


2.  Explain the concept of Punycode in Node.js?


Punycode is an encoding syntax. 

It is used to convert Unicode (UTF-8) string of characters into basic ASCII string of characters. 

As host names only understand the ASCII characters so Punycode is used to convert.

It is used as an internationalized domain name (IDN or IDNA).

punycode.decode(string)
punycode.encode(string)

 3. Is cryptography supported in Node.js?


Yes, Crypto module supports cryptography in Node.js. 


4. Explain the reason as to why Express ‘app’ and ‘server’ must be kept separate?


To increase the optimization, we prefer to keep Express ‘app’ and ‘server’ separate.

Express App:
It encapsulates your API logical, which is your data abstraction. 
This is where you should keep up your DB logic or data models.

Server:
Its sole responsibility is to keep the app/website running. 


5. Explain the purpose of module.exports


When dividing your program code over the multiple files, module.exports is used to publish variables and functions to the consumer of a module. 

The require() call in the source file is replaced with corresponding module.exports loaded from the specified module.


6. What tools can be used to assure consistent style? Why is it important?


Available Tools List:
JSLint
JSHint
ESLint
JSCS

It is important because these tools are very helpful when developing code in teams, to enforce a given style guide and to catch common errors using static analysis.


7. When should you npm and when yarn?


npm and Yarn are two well-known JavaScript package managers. 

npm:
It can be used for all Node.js versions.
It is slower than Yarn.
It offers shrinkwrap CLI command to lock down the versions of package’s dependencies (npm-shrinkwrap.json)

yarn:
When using Node.js version above 5.
Yarn caches all installed packages. 
Yarn is installing the packages simultaneously.
It is faster than NPM.
It generates yarn.lock to lock down the versions of package’s dependencies by default. 


8. What's most used HTTP framework and why?


Express.js and Sails.js


9. How can you secure your HTTP cookies against XSS attacks?


When using express we can consider following things:

Don’t use deprecated or vulnerable versions of Express
Use TLS
Use Helmet
Use cookies securely
Prevent brute-force attacks against authorization
Ensure your dependencies are secure
Avoid other known vulnerabilities


10. How can you make sure your dependencies are safe?


By automate the update / security audit of the dependencies by following methods or tools:

npm outdated - npm outdated / npm outdated -g --depth=0 / npm audit / npm audit fix
Trace by RisingStack
NSP
GreenKeeper
Snyk


Comments:
Content Contributor
Prashant Surya

Prashant Surya

Software developer at Uniserve Data Technologies Pvt. Ltd.  |   Noida, Uttar Pradesh, India

I am a software developer, freelancer and trainer working on technologies likes. MEAN stack, MERN Stack, ASP.NET full stack , SQL, JavaScript, jQuery, HTML, CSS, SEO, responsive UI/UX designing... having 7 years of experience in development in multiple domains like, eCommerce, capital markets, education, real estate...


Read related articles

Node.js Interview Questions and Answers | Part 5

Pooja Goel  |   Dec 30, 2019  |  Views: 222

Node.js Interview Questions and Answers | Part 4

Pooja Goel  |   Dec 30, 2019  |  Views: 274

Node.js Interview Questions and Answers | Part 3

Pooja Goel  |   Dec 30, 2019  |  Views: 155

Node.js Interview Questions and Answers | Part 2

Pooja Goel  |   Dec 27, 2019  |  Views: 124

Node.js Interview Questions and Answers | Part 1

Pooja Goel  |   Dec 27, 2019  |  Views: 320

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