InterviewBuddy
All interview questions

What problem does dependency injection solve?

Beginner

Answer

Dependency injection supplies a class with its dependencies instead of making the class construct them. Nest resolves registered providers and injects them into consumers.

Explanation

This separates configuration from behavior and makes dependencies easier to substitute in tests. Provider registration and module exports determine availability.

Example

constructor(private readonly users: UsersService) {}