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 ?
- Best for Real Time Application.
- Javascript can be run in client side as well as in Server Side.
- Easy to Setup.
- Its lightweight and Fast.
- Well suited for applications that have a lot of concurrent connections.
- Free modules available like socket, MySQL etc
Question: Why I should Not use NodeJS ?
- It runs Javascript, which has no compile-time type checking.
- Nested callback hell.
- Dealing with files can be a bit of a pain.
- 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);