Monday 17 October 2016

NodeJS Interview Questions and Answers for

NodeJS Interview Questions and Answers

Question: Node.js is best suited for what type of application?
Node.js is best suited for real-time applications like Online games, Collaboration Tools, Chat Rooms etc where Real time data required without Refreshing the page.


Question: Why I should use NodeJS ?
  1. Best for Real Time Application.
  2. Javascript can be run in client side as well as in Server Side.
  3. Easy to Setup.
  4. Its lightweight and Fast.
  5. Well suited for applications that have a lot of concurrent connections.
  6. Free modules available like socket, MySQL etc



Question: Why I should Not use NodeJS ?
  1. It runs Javascript, which has no compile-time type checking.
  2. Nested callback hell.
  3. Dealing with files can be a bit of a pain.
  4. Not good for Blogs and static sites.



Question: How do I pass command line arguments to Node.js?
In Command Line
node test.js one two three four five

How to get data
var args = process.argv.slice(2);
console.log(args);



Question: How do I debug Node.js applications?
For you need to install node-inspector
npm install -g node-inspector



Question: How to list local packages installed?
npm list



Question: How to list global packages installed?
npm list -g



Question: How to exit in Node.js?
process.exit()



Question: How to parse JSON using Node.js??
JSON.parse()



Question: How to get GET (query string) variables?
var url = require('url');
var url_parts = url.parse(request.url, true);
var query = url_parts.query;
console.log(query);