I understand from MDN that 'undefined' is recognised as a primitive value, which is corroborated by the ES doco also stating that an "undefined value" is a "primitive value used when a variable has not been assigned a value".
I also understand even though the variable may not be assigned a value (i.e. an uninitialised variable), memory is still allocated for it during the creation of its execution context ('creation' phase) prior to execution happening. This explains why when we attempt to access the variable, we do not get a reference error - rather we just encounter 'undefined' (i.e. in the console log).
Noting the above, my question is, in memory, what does this look like at the memory location of the variable? Is there actually a value at the allocated memory location/address of the undefined variable? Or is the value at the memory address empty (nothing there)? If so, could we then describe the value as null (0x00)?
Thanks.
No. An uninitialised variable is something different than a variable initialised with the value
undefined
. Have a look at this answer explaining the initialisation for various kinds of declarations.It doesn't really matter how this is implemented. Every implementation may do it different, what matters are the observable effects in JS.
Allocated memory always holds some value. It might be a value for which no representation exists in JS, though.