Friday 14 October 2016

NodeJS Interview Questions and Answers for beginners

NodeJS Interview Questions and Answers for beginners

Question: What is NodeJS?
Node.js is a server-side platform.


Question: On which engine built on NodeJS??
Node.js is is built on Google Chrome's JavaScript Engine(V8).


Question: What type of application can be built using NodeJS?
  1. server-side application
  2. networking applications



Question: On which OS it can be run?
  1. OS X (Mac)
  2. Microsoft Windows
  3. Linux



Question: In what type of application we can use NodeJS?
  1. I/O bound Applications
  2. Data Streaming Applications
  3. Data Intensive Real-time Applications (DIRT)
  4. JSON APIs based Applications
  5. Single Page Applications



Question: What is REPL?
REPL is environment to test/debug the code of nodeJS.
Full form of REPL is Read Eval Print Loop.


Question: What is package.json?
package.json define the properties of a package like name, description, version, author, contributors and dependencies.


Question: Where does exist package.json in package?
It exist in root folder of every package.


Question: How to create an API in nodeJS?
var mysql = require("mysql");
var app = require('express')();
var http = require('http').Server(app);
var con = mysql.createConnection('mysql://arun:arun@localhost/enterprisedev2');

app.get('/get/records', function(req, res) {
    con.query('SELECT id,userName,text FROM users where usertype=3', function(err, rows) {
        res.send(rows);
    });
});



Question: How to escape a string while insert into database?
var mysql = require("mysql");
mysql.escape('userdata');