-
What is the purpose of the
res.type()
method in Express.js?- A) To set the HTTP status code of the response
- B) To set the content type of the response
- C) To send an HTTP response with JSON data
- D) To send an HTTP response with HTML content
Answer: B) To set the content type of the response
-
In Express.js, what is the purpose of the
req.app
property?- A) To access the application settings
- B) To access the request headers
- C) To access the route object
- D) To access the base URL of the application
Answer: A) To access the application settings
-
Which of the following middleware is commonly used for logging in Express.js?
- A) express.json()
- B) express.static()
- C) morgan
- D) express-session
Answer: C) morgan
-
What is the purpose of the
res.jsonp()
method in Express.js?- A) To send a JSON response with padding
- B) To redirect the client to a new URL
- C) To send an HTTP response with HTML content
- D) To send an HTTP response with JSON data
Answer: A) To send a JSON response with padding
-
In Express.js, what does the
req.subdomains
property contain?- A) The request method
- B) The request headers
- C) An array of subdomains in the domain name
- D) The route object
Answer: C) An array of subdomains in the domain name
-
What is the purpose of the
res.attachment()
method in Express.js?- A) To set the HTTP status code of the response
- B) To attach a file to the response
- C) To send an HTTP response with JSON data
- D) To send an HTTP response with HTML content
Answer: B) To attach a file to the response
-
In Express.js, what is the purpose of the
req.xhr
property?- A) To check if the request is an XMLHttpRequest
- B) To access the request headers
- C) To access the route object
- D) To access the base URL of the application
Answer: A) To check if the request is an XMLHttpRequest
-
Which of the following Express.js methods is used to handle HTTP TRACE requests?
- A) app.trace()
- B) app.get()
- C) app.post()
- D) app.delete()
Answer: A) app.trace()
-
What is the purpose of the
res.end()
method in Express.js?- A) To send an HTTP response with JSON data
- B) To end the response process
- C) To set the HTTP status code of the response
- D) To redirect the client to a new URL
Answer: B) To end the response process
-
In Express.js, what is the purpose of the
req.route.path
property?
- A) To access the request method- B) To access the request headers
- C) To access the route path pattern
- D) To access the route objectAnswer: C) To access the route path pattern
Comments