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

Why is null == undefined true but null == 0 false?

Short interview answer

The abstract equality algorithm specifically defines null and undefined as loosely equal only to each other and to themselves — they are deliberately excluded from the numeric coercion path that would otherwise compare them to 0.

Key takeaway

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

← Back to Equality and type coercion

Related questions