In a content delivery network (CDN), the process of distributing copies of files to multiple geographically dispersed servers is known as ______.
- Load Balancing
- Replication
- Caching
- Clustering
In a content delivery network (CDN), the process of distributing copies of files to multiple geographically dispersed servers is known as "Replication." This ensures that content is readily available to users from nearby servers, reducing latency and improving load times. Load balancing, caching, and clustering are related concepts but not specific to CDN replication.
What happens to the prototype chain when using Object.create(null) in JavaScript?
- It creates an empty object with no prototype
- It inherits from the Object prototype
- It inherits from the null prototype
- It creates an object with its own prototype chain
Using Object.create(null) in JavaScript creates an empty object with no prototype, effectively removing it from the prototype chain. This is useful in scenarios where you want to create objects without inheriting any properties or methods from the default Object prototype.
To specify a specific version of a package in the package.json file, you can use a ______ to define the exact version number.
- semver
- specifier
- version-lock
- exact
To specify a specific version of a package in the package.json file, you can use a semver specifier to define the exact version number or a range of versions you want to use. Semver specifiers allow for flexibility in specifying version requirements for packages.
You are tasked with optimizing a large-scale application. How would identifying and managing closures help in optimizing the application's memory usage and performance?
- Closures have no impact on memory usage and performance
- Identifying and releasing unnecessary closures can reduce memory consumption and improve performance
- Closures should be created for all functions to improve memory management
- Increasing the use of closures will automatically optimize the application
Identifying and releasing unnecessary closures (option b) can indeed reduce memory consumption and improve performance in large-scale applications. Closures do impact memory usage, and creating too many unnecessary closures can lead to memory leaks and performance issues. Options a, c, and d do not accurately describe the role of closures in optimizing applications.
How does indexing impact the performance of read and write operations in a database?
- It significantly slows down both read and write operations.
- It has no impact on read operations but speeds up write operations.
- It significantly speeds up read operations but has no impact on write operations.
- It significantly speeds up both read and write operations.
Indexing in a database can significantly speed up read operations because it allows the database system to quickly locate specific records. However, it can slightly slow down write operations because the database needs to update the index when new data is inserted or existing data is updated.
How can you implement template inheritance in Pug?
- extend layout.pug
- include layout.pug
- inherit layout.pug
- template layout.pug
In Pug, template inheritance is implemented using the extend keyword followed by the name of the layout file. This allows child templates to inherit the structure and content of the specified layout file. The other options (include, inherit, and template) are not used for template inheritance in Pug.
How can you optimize the performance of a SQL query that reads a large amount of data?
- Use indexes on columns frequently queried.
- Avoid joins and subqueries.
- Increase the page size of the database.
- Fetch all data at once to minimize network latency.
To optimize the performance of a SQL query reading large data, you should use indexes on columns frequently queried. Indexes improve data retrieval speed. The other options may not necessarily lead to performance improvements and can even degrade performance.
You are developing a Node.js application that should gracefully shut down when it receives a termination signal. How would you accomplish this using the process object?
- process.on('terminate', () => { /* Graceful shutdown code */ });
- process.kill('SIGTERM', process.pid);
- process.exit(0);
- process.handleTermination(() => { /* Graceful shutdown code */ });
To gracefully shut down a Node.js application upon receiving a termination signal, you should use process.on('terminate', () => { /* Graceful shutdown code */ });. This registers an event handler for the 'terminate' event. The other options either do not handle termination signals gracefully or are incorrect syntax.
You are tasked with implementing a secure authentication system for a web application. What considerations should you make to ensure the security of user credentials and session information?
- Store passwords in plain text
- Use a secure hashing algorithm for password storage
- Use HTTP for transmitting sensitive data
- Keep session tokens in local storage
To ensure the security of user credentials and session information, you should use a secure hashing algorithm (like bcrypt) to store passwords, not store them in plain text. Additionally, sensitive data should not be transmitted over HTTP, and session tokens should be stored securely (not in local storage, which is vulnerable to cross-site scripting attacks).
What considerations should be made when deciding between using a mock and a stub in a test case?
- The complexity of the test scenario
- The need for recording method calls
- The desire to control method behavior
- The size of the test data
When deciding between using a mock and a stub in a test case, considerations should include the complexity of the test scenario, as mocks are generally more complex than stubs. Recording method calls is a characteristic of mocks, and controlling method behavior is a characteristic of stubs. The size of the test data is typically not directly related to choosing between mocks and stubs.