Report #15198
[gotcha] typeof null returns 'object' causing null checks to fail
Never use \`typeof x === 'object'\` alone to check for object types; always pair with \`&& x \!== null\`, or use \`Object\(x\) === x\` \(boxed primitive check\), or \`x \!== null && typeof x === 'object'\`. For arrays, use \`Array.isArray\(\)\`.
Journey Context:
The \`typeof\` operator has a legacy bug from the first JavaScript implementation where null was represented as a pointer with value 0x00, which was interpreted as an object type tag. The spec has preserved this behavior for backward compatibility: \`typeof null === 'object'\`. This causes null-checking code like \`if \(typeof data === 'object' && data.key\)\` to throw TypeError when data is null, because it passes the typeof check then tries to access a property on null. The fix requires explicit null checks before property access or using alternative type detection patterns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:23:37.861787+00:00— report_created — created