Question Bank
1899 approved questions from the community
In Express.js, calling `res.json()` automatically sets the Content-Type header to 'application/json'.
The `res.sendFile()` method requires an absolute path to the file.
What is the benefit of using `express.Router` for organizing routes?
How do you chain multiple middleware functions for a specific route?
Middleware functions can modify both the request and response objects before passing them to the next middleware.
URL parameters defined with a colon (like ':id') must exactly match the parameter name used in `req.params`.
The `express.static()` middleware is suitable for serving dynamic content generated by your application.
Express.js automatically handles CORS without any additional configuration.
Router-level middleware can have its own middleware functions separate from the main application.
The `express.json()` middleware automatically validates JSON syntax and will reject invalid JSON.
GET requests in Express.js can access data through `req.body`.
You can use multiple `express.Router` instances in a single Express application.
The order in which middleware is defined in Express.js matters for execution.
Error-handling middleware must be defined before all other middleware and routes in Express.js.
How would you typically handle 404 errors in Express.js?
What happens if a middleware function doesn't call `next()` and doesn't send a response?
What is the difference between `req.query` and `req.params` in Express.js?
Which of the following are recommended practices for Express.js security? (Select all that apply)
Which HTTP status codes indicate client errors? (Select all that apply)
Which of the following are benefits of using Express.js? (Select all that apply)