In which of the following template engines can you write plain JavaScript code inside special tags?

  • Mustache
  • Handlebars
  • Pug
  • EJS (Embedded JavaScript)
EJS (Embedded JavaScript) allows you to write plain JavaScript code inside special tags <% %> or <%= %>. This feature is useful for executing JavaScript logic and generating dynamic content within templates. Mustache, Handlebars, and Pug have their own template syntax and do not support this feature in the same way.

Which of the following Node.js modules would you typically use to handle file uploads?

  • fs
  • http
  • url
  • multer
In Node.js, to handle file uploads, you would typically use the multer module. multer is a middleware for handling multipart/form-data, which is the format used for file uploads. The other options (fs, http, and url) are commonly used for different purposes, such as working with files, creating HTTP servers, and parsing URLs, respectively.

What is the primary use of the File System (fs) module in Node.js?

  • Manipulating and interacting with files and directories
  • Parsing JSON data
  • Creating web servers
  • Handling user input
The primary use of the File System (fs) module in Node.js is for manipulating and interacting with files and directories. It provides methods for reading, writing, updating, and deleting files, as well as working with directories.

The global object in Node.js is similar to the ______ object in client-side JavaScript.

  • window
  • document
  • navigator
  • console
In Node.js, the global object is similar to the window object in client-side JavaScript. It provides access to global variables and functions across the Node.js application.

When using template engines like EJS or Pug with Express.js, the ______ method is used to render a view template.

  • render
  • send
  • view
  • generate
In Express.js, the render method is used to render a view template when using template engines like EJS or Pug. It takes the name of the view and an optional data object as parameters. The other options are not typically used for rendering view templates.

How can you optimize Sequelize queries to avoid retrieving unnecessary data from the database?

  • Using the attributes option to specify only the required fields
  • Using findAll without any options
  • Using findOne for all queries
  • Using SELECT * for all queries
To optimize Sequelize queries, you can use the attributes option to specify only the fields you want to retrieve. Using findAll without options would retrieve all fields, which is inefficient. Using findOne is not suitable for all queries, and using SELECT * would retrieve all fields.

How can LIMIT and OFFSET be used effectively to optimize SQL queries?

  • Use LIMIT to specify the maximum number of rows to retrieve and OFFSET to skip a certain number of rows.
  • Use OFFSET to specify the maximum number of rows to retrieve and LIMIT to skip a certain number of rows.
  • Use LIMIT and OFFSET together to retrieve all rows in a table.
  • Use LIMIT and OFFSET to restrict the number of columns retrieved in a query.
LIMIT is used to restrict the number of rows in the result set, while OFFSET is used to skip a certain number of rows. This is helpful for paginating results and optimizing queries when you don't need to retrieve the entire dataset.

Which of the following strategies can be used to efficiently serve static assets and optimize performance?

  • Caching static assets at the server-side.
  • Using long, descriptive file names for static assets.
  • Serving static assets through a Content Delivery Network (CDN).
  • Storing static assets in a database.
Serving static assets through a Content Delivery Network (CDN) is an efficient strategy to optimize performance by distributing assets across geographically distributed servers, reducing latency and improving load times. The other options either don't directly address performance optimization or provide incorrect methods.

What does JWT stand for in the context of web security?

  • JavaScript Web Token
  • JSON Web Token
  • JavaScript Web Transfer
  • JSON Web Transfer
JWT stands for JSON Web Token. It is a compact, self-contained means for securely transmitting information between parties as a JSON object. JWTs are commonly used for authentication and authorization in web security. The other options are not accurate acronyms for JWT.

Why is it important to define the correct path for serving static files in Express.js?

  • To improve security by hiding static files.
  • To enhance performance by reducing load times.
  • To avoid conflicts with route handling.
  • To simplify the code structure.
Defining the correct path for serving static files in Express.js is important to avoid conflicts with route handling. If the path is not specified correctly, Express.js might mistakenly interpret a URL as a route, leading to unexpected behavior. The other options, while important, are not the primary reason for specifying the correct static file path.