Skip to content
JavaScript·Intermediate·Conceptual·1 min read

What's the main cost of using a singleton?

Short interview answer

It introduces shared, persistent state across the entire application lifetime, which makes unit testing harder — one test's mutation of the singleton can leak into the next test unless the singleton is explicitly reset between tests.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to JavaScript design patterns

Related questions