Null is a special value that represents the absence of a value or a reference that points to nothing. Different languages use different names, such as null, nil, None or NULL, and they differ in how it behaves.
Why it matters
Null is useful for signaling "no result" or "not set", but dereferencing it, calling a method on a missing object, is one of the most common crashes (NullPointerException in Java, TypeError in JavaScript). Tony Hoare, who introduced null references in 1965, later called it his "billion-dollar mistake". Newer languages reduce the risk with types that make absence explicit, such as Kotlin's nullable types, Swift and Rust Optionals, and TypeScript's strict null checks. In SQL, NULL means unknown and behaves differently: NULL = NULL is not true.
Example
const user = findUser("ana"); // may return null
console.log(user.name); // TypeError if user is null
console.log(user?.name ?? "guest"); // safe: optional chaining
Common mistakes
- Using
0, an empty string and null interchangeably. - Using
= NULLin SQL instead ofIS NULL. - Returning null from a function that should return an empty list.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.