> ## Content Index
> Fetch the complete content index at: https://atomic-noggin-bloggin.ghost.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# The secret third "empty" value in JS
- URL: https://atomic-noggin-bloggin.ghost.io/the-secret-third-empty-value-in-js/
- Published: 2026-11-14T18:39:42.000Z
- Updated: 2026-11-14T18:39:42.000Z
- Description: Anyone familiar with JavaScript is aware of null and undefined. However, the difference between them is not always well known. Even less known is the existence of a secret empty value.
- Author: Patrick Denny

Anyone familiar with JavaScript is aware of **null** and **undefined**. However, the difference between them is not always well known. Even less known is the existence of a secret **empty** value.

**null** is the intentional absence of a value. It is the symantic assertion that a variable, property, or return value is "empty". **null** was intended to be a choice you make in your code.

**undefined** is a variable (or property) that has not been assigned a value. It is quite literally, the lack of any value at all – the default value provided when a variable is initialized without an initial value, or the return value of a method that has none specified. **undefined** was intended to be the result of not making a choice.

**empty** is the lack of a property at all. It isn't a code choice, per se. It's the lack of code altogether. Its not normally considered a value since there usually isn't anything to hold "empty" in, but in one particular case, there is. 

##  The history of *undefined*

Initially **undefined** wasn't even a true value ether (or even a reserved word). It was a magic statement that appeared in your log files if you printed out a non-existent value or result, or coerced it to a string in code. You could test for it in one of three ways:

- **if (typeof myVar == "undefined")**  
explicitly check if it's type was "undefined" (note the loose comparison == is used here because strict comparison wan't a thing back then either)
- **if (myVar == void 0)**  
compare it to the builtin **void** method, which "returns" undefined.
- **if (myVar == IS\_UNDEFINED)**  
compare it to a variable specifically created to "contain" an undefined value.

It first became a true primitive value (like **true** and **false**) with [release of JavaScript 1.3](https://lia.disi.unibo.it/materiale/JS/developer.mozilla.org/en-US/docs/Web/JavaScript/New%5Fin%5FJavaScript/1-3.html?ref=atomic-noggin-bloggin.ghost.io#New%5Fglobals) in 1998 and formalized as part of the ECMAScript 3 standard. You could now test for it directly ( **myVar === undefined**). Later on, it was made non-configurable, non-writable property of the global scope, to stop it from being overwritten in ***strict mode***.

However, now that **undefined** is a true primitive value, it does mean you *can* explicitly "set" a variable, property, or argument default to **undefined** if you want, as well as "resetting" (or "unsetting") them back to their **undefined** state. This makes it *functionally equivalent* to **null** – hence the introduction of the ***nullish*** operators and optional chaining – even if it still retains it's symantic difference.

But what if you don't care if something's value is "empty"? What if you need to know if something exists at all?

## Finding something that isn't there

If **null** is an intentional empty value and **undefined** is a non-existent value, what if you want to determine if the thing whose value you are checking is itself non-existent? What if you need to know if something is *missing entirely*? The only way to determine that is by inference, if possible. 

Checking for missing variables is either reasonably easy or somewhat impossible. Thanks to ***strict mode*** you can simply try to reference the missing variable; this will throw a ReferenceError that you can capture in a **try/catch** block. However, **strict mode** is opt-in with a scope-specific *magic* "use strict" invoker string. By default, "[sloppy mode](https://developer.mozilla.org/en-US/docs/Glossary/Sloppy%5Fmode?ref=atomic-noggin-bloggin.ghost.io)" JavaScript will auto generate a new variable in global scope on first reference, making the **try/catch** method useless. That said, because globally scoped variables (including auto-generated ones) are also properties of globalThis/window (depending on context) so you can test for the existence of those, if need be. 

Checking for missing properties on objects directly is not possible. When referencing a missing property (e.g. **myObject.notAProperty**) JavaScript, even in ***strict mode***, coerces to the default **undefined**. That said, there are a few ways to indirectly check for a property's existence:

- Use **Object.keys(myObject)** to get an array of enumerable property names, or **Object.getOwnPropertyNames(myObject)** to get all of an object's property names , including non-enumerable ones. Useful for determining multiple properties' existence.
- **("notAProperty" in myObject)** will return false if the named property does not exist, regardless of it's enumerably. It will, however walk the object's prototype chain, so inherited properties will also be found.
- **myObject.hasOwnProperty("notAProperty")** will return false if property does not exist without walking the prototype chain. It will throw an TypeError if the object itself is **undefined**, **null**, or [has a null prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global%5FObjects/Object?ref=atomic-noggin-bloggin.ghost.io#null-prototype%5Fobjects)
- **Object.hasOwn(myObject,"notAProperty")** will return false if property does not exist without walking the prototype chain or throwing a TypeError.

## "Empty": Missing as a value.

What about missing entries in an array? Since an array represents a collection of values, it is inferred that an arrays length is equal to the number of entries within it; but – with [sparsely populated arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed%5Fcollections?ref=atomic-noggin-bloggin.ghost.io#sparse%5Farrays) – it is possible to have arrays with missing (or **empty)** entries, like so:

![A close up screenshot of a Chrome DevTools console entry. It's first input line reads [,null,undefined]. It's second output line reads (3) [empty, null, undefined]](https://storage.ghost.io/c/30/34/3034843d-20e6-4d78-9f64-db682ce8c09a/content/images/2026/11/image.png)

An array with three different values that mean **nothing.*

Now, as with missing properties, you can't directly reference an **empty** array entry – it's coerced to **undefined –** but you can use the same methods to infer an entry's "emptiness". **Object.hasOwn(myArray,0)** will return **false** if the entry is **empty**.

This is the only place where our magical **empty** value exists. Even functions default to returning **undefined** if no return value or statement exists. If you ever need a method to return a "missing" value, instead of **null**, or **undefined (**or any other value), you can only do so by passing back an **empty** entry in an array and infering its (lack of) presence afterwards.

![Another Chrom DevTools conole screenshot with three lines of input and their resulting output. input 1: (function returnNothing() { return; })(); output 1: undefined input 2: (function noReturn() {})(); output 2: undefined input 3: (function returnEmpty() { return (, ] })() output 3: [empty]](https://storage.ghost.io/c/30/34/3034843d-20e6-4d78-9f64-db682ce8c09a/content/images/2026/11/image-1.png)

Passing back "nothing" vs. passing back empty.

While there isn't typically a big need to differentiate between **null,** **undefined**, and **empty**;if you've ever needed to parse, stringify, transform, and/or compact data-structures to pass between systems, windows, or workers, then you may need to know specifically if a something is intentionally empty, missing it's value, or missing entirely. Now you can.