-
Which of the following is NOT a built-in middleware function in Express.js?
- A) express.json()
- B) express.static()
- C) express.urlencoded()
- D) express.validate()
Answer: D) express.validate()
-
In Express.js, what is the purpose of the
res.cookie()
method?- A) To send an HTTP response with JSON data
- B) To set cookies in the client's browser
- C) To send an HTTP response with HTML content
- D) To redirect the client to a new URL
Answer: B) To set cookies in the client's browser
-
Which of the following is a common template engine used with Express.js for server-side rendering?
- A) React
- B) Angular
- C) Vue.js
- D) EJS
Answer: D) EJS
-
What does REST stand for in the context of web services?
- A) Real-time Service Technology
- B) Remote Execution Service Toolkit
- C) Representational State Transfer
- D) Responsive Service Transformation
Answer: C) Representational State Transfer
-
In Express.js, what does the
req.originalUrl
property return?- A) The original URL requested by the client
- B) The current URL of the request
- C) The base URL of the application
- D) The query string of the URL
Answer: A) The original URL requested by the client
-
Which method is used to set up route-specific middleware in Express.js?
- A) app.use()
- B) app.route()
- C) router.use()
- D) router.route()
Answer: C) router.use()
-
What is the purpose of the
express.Router()
function in Express.js?- A) To define route-specific middleware
- B) To create an instance of the Express application
- C) To define route handlers
- D) To initialize the Express.js server
Answer: A) To define route-specific middleware
-
In Express.js, how can you access route parameters?
- A) Using
req.query
- B) Using
req.body
- C) Using
req.params
- D) Using
req.headers
Answer: C) Using
req.params
- A) Using
-
Which of the following middleware is commonly used for session management in Express.js?
- A) express.json()
- B) express.static()
- C) express-session
- D) express.urlencoded()
Answer: C) express-session
-
What is the purpose of the
req.baseUrl
property in Express.js?- A) To access request query parameters
- B) To access the base URL of the application
- C) To access URL route parameters
- D) To access request body parameters
Answer: B) To access the base URL of the application
Comments