In JavaScript: Understanding the strange parts, the instructor explains that the memory for variables is tuned during the so-called creation phase (and that undefined
); then a run phase occurs. But why is this useful when we do not know which value (s) the value will later point to?
It is clear that variables can point to many different things - for example, a short string up to the deeply nested structure of an object - and I assume that they can vary greatly in the amount of memory they need.
If phased execution, including variable assignment, appears only at a later stage of execution, how can the initial phase of creation know how to tune memory? Or, is memory reserved only for the name in each pair of variable name / value, with memory for managing the value differently?
source
share