-
What is the purpose of the
req.query
object in Express.js?- A) To access request query parameters
- B) To access request headers
- C) To access URL route parameters
- D) To access request body parameters
Answer: A) To access request query parameters
-
In Express.js, what does the
app.locals
object do?- A) Stores application-wide data accessible in all views
- B) Stores request-specific data accessible in middleware
- C) Provides access to request query parameters
- D) Manages session data for users
Answer: A) Stores application-wide data accessible in all views
-
Which Express.js method is used to handle HTTP DELETE requests?
- A) app.delete()
- B) app.put()
- C) app.get()
- D) app.post()
Answer: A) app.delete()
-
What is the purpose of the
res.status()
method in Express.js?- A) To set the HTTP status code of the response
- B) To send an HTTP response with JSON data
- C) To send an HTTP response with HTML content
- D) To redirect the client to a new URL
Answer: A) To set the HTTP status code of the response
-
Which of the following Express.js methods is used to mount a router on a route path?
- A) app.use()
- B) app.route()
- C) router.use()
- D) router.route()
Answer: A) app.use()
-
Which of the following Express.js methods is used to handle HTTP PUT requests?
- A) app.put()
- B) app.get()
- C) app.post()
- D) app.delete()
Answer: A) app.put()
-
What is the purpose of middleware in Express.js?
- A) To define routes for handling HTTP requests
- B) To handle database operations
- C) To manipulate request and response objects
- D) To render views with data
Answer: C) To manipulate request and response objects
-
What does MVC stand for in the context of web development?
- A) Model View Controller
- B) Maximum Volume Control
- C) Most Valuable Code
- D) Minimal View Complexity
Answer: A) Model View Controller
-
In Express.js, which method is used to handle HTTP PATCH requests?
- A) app.patch()
- B) app.put()
- C) app.post()
- D) app.delete()
Answer: A) app.patch()
-
What is the purpose of the
req.headers
object in Express.js?- A) To access request query parameters
- B) To access request headers
- C) To access URL route parameters
- D) To access request body parameters
Answer: B) To access request headers
Comments