NodeJS expressjs quiz

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications and being one of most popular NodeJS framework today

This quiz is in NodeJS quiz collection.

Start quiz
  • 1.

    How to store local variables that can be access within the application?

  • 2.

    In ExpressJS, the method app.all(path, callback [, callback ...]) can accept all HTTP methods

  • 3.

    What should you do in your code to improve your application’s performance?

    (Multiple choices)

  • 4.

    Route paths, in combination with a request method, define the endpoints at which requests can be made.

    Which of following are valid form of route path?

  • 5.

    Where is captured values are populated regarding route parameters?

  • 6.

    Select all valid rout parameter formats

  • 7.

    How many number of callback functions can be attached to handle a request?

  • 8.

    Is the below code valid?

    var cb0 = function (req, res, next) {
      console.log('CB0')
      next()
    }
    var cb1 = function (req, res, next) {
      console.log('CB1')
      next()
    }
    var cb2 = function (req, res) {
      res.send('Hello from C!')
    }
    app.get('/example/c', [cb0, cb1, cb2])
  • 9.

    Is the code below valid?

    var cb0 = function (req, res, next) {
      console.log('CB0')
      next()
    }
    var cb1 = function (req, res, next) {
      console.log('CB1')
      next()
    }
    app.get('/example/d', [cb0, cb1], function (req, res, next) {
      console.log('the response will be sent by the next function ...')
      next()
    }, function (req, res) {
      res.send('Hello from D!')
    })
  • 10.

    The methods on the response object (res) in the following table can send a response to the client, and terminate the request-response cycle. If none of these methods are called from a route handler, the client request__________

    Method Description
    res.download() Prompt a file to be downloaded.
    res.end() End the response process.
    res.json() Send a JSON response.
    res.jsonp() Send a JSON response with JSONP support.
    res.redirect() Redirect a request.
    res.render() Render a view template.
    res.send() Send a response of various types.
    res.sendFile() Send a file as an octet stream.
    res.sendStatus() Set the response status code and send its string representation as the response body.
  • 11.

    How can we create chainable route handlers for a route path in ExpressJS app?

© 2017 QuizBucket.org