Fs module provides both synchronous as well as asynchronous methods.
AnswerHow can we create chainable route handlers for a route path in ExpressJS app?
AnswerThe 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. |
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!')
})
Answer
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])
Answer
How many number of callback functions can be attached to handle a request?
AnswerSelect all valid rout parameter formats
AnswerWhere is captured values are populated regarding route parameters?
AnswerRoute 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?
AnswerWhat should you do in your code to improve your application’s performance?
(Multiple choices)
AnswerIn ExpressJS, the method app.all(path, callback [, callback ...]) can accept all HTTP methods
AnswerHow to store local variables that can be access within the application?
AnswerIf an EventEmitter
does not have at least one listener registered for the 'error'
event, and an 'error'
event is emitted, the error is thrown, a stack trace is printed, and the Node.js process ____.
Which method can be used to handle an event just only one time?
AnswerHow many listenners can be attached to an event in NodeJS?
AnswerBy default EventEmitters will print a warning if more than ______
listeners are added for a particular event
Which methods can be use to switch listener functions asynchronous mode:
AnswerWhen the EventEmitter
object emits an event, all of the functions attached to that specific event are called _______. Any values returned by the called listeners are ignored and will be discarded.
All objects that emit events are instances of the EventEmitter
class
What are Nodejs characteristics?
Answer© 2017 QuizBucket.org