Bart said:
Then you're contradicting yourself. If the undefined value is always
"assigned" first in javascript, then each variable is first undefined
before it gets any other ("new") value.
You are speaking of "undefined" as if it was a state, when it is in
reality a value in javascript. Because variables in javascript are
properties of objects there is no state of being not defined, just a
states of an object either having a property or its not having a
property. If an object has a property then that property has a value.
That's why I try to avoid analogies; you can twist them any way you
like to prove some point.
Or maybe see in an analogy an inconvenient truth.
It's about the act of the programmer. When you name the box,
you don't say anything about what's in it. After you named the
box, then you name its content. You can only do one thing at
a time.
But whatever is considered as "one thing" will depend on the language
being written. The act of creating a new property of an object includes
the assignment of a value to that property. That combination of
internal behaviour is indivisible at the javascript level, so the whole
operation is "one thing".
Correct, the variable itself remains available. It are the bytes that
are freed when the _value_ is released; those bytes are no longer
needed and added to the free RAM again.
The bytes that are occupied by the value may be freed but assigning the
undefined value (which is the context in which you originally mentioned
memory being freed: "(or make it undefined again (free up the
memory))") has no more than a coincidental relationship to that.
Assigning any value may enable the bytes associated with a previous
value to be freed.
The number of bits or bytes doesn't matter; it's only the principle.
Fact is that the empty string must be defined, and the undefined
string must not be defined,
What "undefined string"?
otherwise it wouldn't logically be undefined anymore.
There is no meaning to "undefined string" in javascript.
The empty string has more in common with the non-empty string
than with Undefined.
More in common? It has its type in common, but it shares its absence of
true-ness with undefined, null, NaN, zero, boolean false and some
objects.
I wouldn't say it specifically applies to this or that, but it
applies to the general principles of RAM.
Should the "general principles of RAM" be considered relevant to a
language that never deals in terms of RAM?
But even so you are not dealing with the "general principles of RAM"
when you speak of named variables. Associating names with memory
locations is something that comes into computer languages as a
convenient alternative to using memory addresses directly. It comes in
at a level above machine code, maybe by the level of sophisticated
assembly languages and certainly by the time you get to C and similar
languages. But in the same way as introducing named variables can
abstract away details like memory addresses, javascript has abstracted
away details like numbers of bytes associated with names.
I've had many long conversations in
the past with my dad who worked in a team that fabricated and supported
bespoke computers in the '60-'70. He wrote books about it. Computers
with no screen, no keyboard, just punch cards with bit ranges as ROM
and a couple of halls full of bulbs for the RAM. For me it's clear that
any computer still works using the same principles, only the byte scale
has enormously increased.
Of course computers work the same, and they still execute machine code.
We are programming at a level well above machine code, and with
javascript a level well beyond any interest in the specifics of memory
allocation, and writing bit patterns into memory locations.
How defined/undefined affects (or doesn't) the machine's CPU.
Where undefined is a value (the single value of the undefined type)
what is 'defined' and what sense is "defined/undefined" intended to
convey?
What point, and how does the ability to create strings sufficiently
large that their presence in memory is easily observed prove it?
Richard.