Express Js Interview Questions & Answers

1. What is Express Js?  

Express JS is a framework which helps to develop web and mobile applications. Its works on nodejs plateform. Its sub part of node.js.

2. What type of web application can built using Express JS?  

You can build single-page,multi-page,and hybrid web applications.

3. What are core features of Express framework?  

  1. Allows to set up middlewares to respond to HTTP Requests.
  2. Defines a routing table which can works as per HTTP Method and URL.
  3. Dynamically render HTML Pages.

4. Why I should use Express JS?  

Express 3.x is a light-weight web application framework to help organize your web application into an MVC architecture on the server side.

5. How to get variables in Express.js in GET Method?  

var express = require('express');
var app = express();

app.get('/', function(req, res){
    /* req have all the values **/  
  res.send('id: ' +;  

6. How to get POST a query in Express.js?  

var bodyParser = require('body-parser')
app.use( bodyParser.json() );       // to support JSON-encoded 
app.use(bodyParser.urlencoded({     // to support URL-encoded 
  extended: true

7. How to output pretty html in Express.js?  

app.set('view options', { pretty: true });

8. How to get the full url in Express?  

var port = || cfg.port;
res.locals.requested_url = req.protocol + '://' +  + ( port == 80 || port == 443 ? '' : ':'+port ) + req.path;

9. How to remove debugging from an Express app?  

var io = require('').listen(app, { log: false });
io.set('log level', 1); 

10. How to 404 errors?  

app.get('*', function(req, res){
  res.send('what???', 404);

11. How to download a file?  

app.get('/download', function(req, res){
  var file = __dirname + '/download-folder/file.txt';; 

12. What is the parameter "next" used for in Express?  

app.get('/userdetails/:id?', function(req, res, next){

13. req and res represents what?  

req and res which represent the request and the response objects.

14. What is the use of next?  

next -It passes control to the next matching route.
OR a function to pass control to one of the subsequent route handlers.

The argument may be omitted, but is useful in cases where you have a chain of handlers and you would like to pass control to one of the subsequent route handlers, and skip the current one.

.Net Interview Question

PHP Interview Question

Java Interview Question

AngularJS Interview Questions