You seem to be confused by that answer stating that "null
is not a value", or that it means "a variable having no value". That's wrong, and that's not what it says.
The null
value is very much a value in the domain of the JS language. It's a primitive value just like undefined
, true
, NaN
, 0
or 42
.
The answer you quoted says that this value can represent a "no value" in your application domain. Putting the value null
there means that it has no other value, e.g. being "neither true nor false".
(And whichever JS value we are looking at, we are not concerned with its bit-level representation in memory, like which bit exactly would distinguish a string from an integer. They're just values that we can work with in our program, and there are no others.
In fact a let
variable in JS can indeed have a state of being uninitialised, but that doesn't mean there is a random bit pattern we can read back, but rather it's an explicit state that causes the program to throw an exception when the variable is evaluated. And var
variables are always initialised, with the undefined
value when a scope is created.)