Full-Stack Development Developer 3 — Questions and Answers
Question 1: Which of the following best describes the difference between `==` and `===` in JavaScript?
- `==` checks value and type; `===` checks value only
- `===` checks value and type; `==` performs type coercion before comparing (Correct answer)
- They are identical in modern JavaScript
- `===` is only valid in strict mode
Correct answer: `===` checks value and type; `==` performs type coercion before comparing
`===` (strict equality) compares both value and type with no coercion, while `==` converts types before comparing.
Question 2: What is the primary advantage of using a message queue (e.g., RabbitMQ, Redis Streams) in a full-stack application?
- It replaces the need for a database
- It decouples producers and consumers, allowing async processing (Correct answer)
- It speeds up synchronous API responses
- It automatically handles database migrations
Correct answer: It decouples producers and consumers, allowing async processing
Message queues allow different parts of the system to communicate asynchronously, improving resilience and scalability.
Question 3: In CSS, what is the box model and which property controls the sizing behavior?
- A grid layout system; controlled by `display: grid`
- The layering of z-index values; controlled by `position`
- The set of boxes (content, padding, border, margin) that wrap every element; controlled by `box-sizing` (Correct answer)
- A flexbox alignment model; controlled by `align-items`
Correct answer: The set of boxes (content, padding, border, margin) that wrap every element; controlled by `box-sizing`
The CSS box model describes the rectangular boxes generated for elements, and `box-sizing: border-box` makes width/height include padding and border.
Question 4: What does the `async/await` syntax in JavaScript do under the hood?
- Creates new threads for parallel execution
- Converts synchronous code to run in a Web Worker
- Wraps Promises so they can be written in a synchronous-looking style (Correct answer)
- Eliminates the event loop for async tasks
Correct answer: Wraps Promises so they can be written in a synchronous-looking style
`async/await` is syntactic sugar over Promises; `await` pauses execution of the async function until the Promise resolves.
Question 5: When should you use `useMemo` in a React component?
- To memoize a callback function reference
- To cache the result of an expensive computation between renders (Correct answer)
- To avoid re-rendering child components when props change
- To persist a value across component unmount/remount cycles
Correct answer: To cache the result of an expensive computation between renders
`useMemo` caches the result of a function and recomputes it only when its dependencies change, avoiding expensive recalculations on every render.
Question 6: What is a database transaction and why is it important?
- A scheduled backup of the database
- A group of operations executed as a single atomic unit, ensuring data consistency (Correct answer)
- A method for encrypting sensitive columns
- A query plan generated by the database optimizer
Correct answer: A group of operations executed as a single atomic unit, ensuring data consistency
Transactions follow ACID properties, ensuring that a set of operations either all succeed or all fail, preventing partial updates.
Question 7: Which tool is commonly used to manage and version control database schema changes in full-stack projects?
- Webpack
- ESLint
- A database migration tool like Flyway, Liquibase, or Prisma Migrate (Correct answer)
- Docker Compose
Correct answer: A database migration tool like Flyway, Liquibase, or Prisma Migrate
Migration tools track incremental schema changes in version-controlled files, allowing teams to apply changes consistently across environments.
Which of the following best describes the difference between `==` and `===` in JavaScript?