Programming FundamentalsBeginner
Null vs Undefined
PronunciationNUL versos UN-de-fined
Definition
null represents an intentional absence of any object value, while undefined means a variable has been declared but not yet assigned a value.
Where you hear it
During code reviews, debugging missing data, or checking API response payloads in JavaScript and TypeScript.
Examples
Declaring a variable without a value automatically sets its state to
undefined.Developers explicitly assign
nullto clear a variable or indicate a missing resource.
Common mistake
Treating them as completely interchangeable, leading to unexpected type errors when checking optional properties.
Keep exploring
More in Programming Fundamentals