CodeZettaInterview Hub

TypeScript · Type Narrowing · Mid-Level · Debugging

Truthy narrowing pitfalls?

Short Interview Answer

Empty string/0/NaN are falsy — may incorrectly narrow away valid values.

Detailed Explanation

Prefer explicit null checks for those domains. == null catches null and undefined.

Did you know this answer?