Home / CSE MCQs / ExpressJS ::

CSE MCQs :: ExpressJS

  1. What are core features of Express framework?
  2. A.
    Allows to set up middlewares to respond to HTTP Requests
    B.
    Defines a routing table which can works as per HTTP Method and URL
    C.
    Dynamically render HTML Pages
    D.
    All of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the below code in the console?
    File: my_module.js
    exports.name = 'Zeus';
     
    Code:
    var my_module = require('./mymodule');
    console.log((function(settings){
        return settings.split('').reverse().join('')
    })(my_module.name));
  4. A.
    Error
    B.
    Zeus
    C.
    undefined
    D.
    sueZ

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. How to store local variables that can be access within the application?
  6. A.
    Using app.locals
    B.
    Using app.storage
    C.
    Using database
    D.
    Config file

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. 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?
  8. A.
    strings
    B.
    string patterns
    C.
    regular expressions
    D.
    All of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Where is captured values are populated regarding route parameters?
  10. A.
    req.params object
    B.
    app.locals object
    C.
    req.data object
    D.
    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What function arguments are available to Express.js Route handlers?
  12. A.
    req - the request object
    B.
    res - the response object
    C.
    next
    D.
    All of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. How can we create chainable route handlers for a route path in ExpressJS app?
  14. A.
    Using app.route()
    B.
    Using app.router()
    C.
    Using app.routing()
    D.
    All of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What are the commands are used to enable debugging in Express App?
  16. A.
    Linux
    B.
    Windows
    C.
    Both A and B
    D.
    None

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. In ExpressJS, the method app.all(path, callback [, callback ...]) can accept all HTTP methods
  18. A.
    True
    B.
    False
    C.
    Insufficient data
    D.
    None

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Imagine that you sent following ajax request:
    $.post("/process", {name:'john'}, function(data){
        // Do some stuff
    });
     
    What will be the answer from the server?
    Tip: On server side, we have the code which is given below
     
    Code:
    app.post('/process', function(req, res){
        var data = '';
     
        if(req.xhr){
            data += 'One';
        }
     
        if(req.body.name){
            data += 'Two';
        }
     
        res.send(data);
    });
  20. A.
    OneTwo'
    B.
    'One'
    C.
    'Two'
    D.
    All of these

    View Answer

    Workspace

    Discuss Discuss in Forum