Bill

Fundamentals of Javascript

Execution Context & it’s stack

https://stackoverflow.com/questions/12599965/lexical-environment-and-function-scope

Execution Context & Execution Context Stack : Execution context is the internal javascript construct to track execution of a function or the global code. The js engine maintains a stack data structure – execution context stack or call stack, which contains these contexts and the global execution context stays at the bottom of this stack. And a new execution context is created and pushed to the stack when execution of a function begins. A particular execution context tracks the pointer where statement of the corresponding function is being executed. An execution context is popped from the stack when corresponding function’s execution is finished.

Lexical Environment : it’s the internal js engine construct that holds identifier-variable mapping. (here identifier refers to the name of variables/functions, and variable is the reference to actual object [including function type object] or primitive value). A lexical environment also holds a reference to a parent lexical environment.

Now, for every execution context — 1) a corresponding lexical environment is created and 2) if any function is created in that execution context, reference to that lexical environment is stored at the internal property ( [[Environment]] ) of that function. So, every function tracks the lexical environment related to the execution context it was created in.

And every lexical environment tracks its parent lexical environment (that of parent execution context). As a result, every function has a chain of lexical environments attached to it. [Note: in js a function is an object, creating a function by a statement means creating an object of type Function. So like other objects, a function can hold properties both internal and user defined]

Scope : it’s the language agnostic concept, to refer to the visibility of variables or functions to the executing code. In js a variable or function is visible to the executing code, if it is there in the current lexical environment or in the lexical-environment-chain of the enclosing function. In case of global code, the chain does not exist.

Note: similar to function’s case, by the introduction of let and const in es6, when a block begins to execute (if block, for loop block etc), a new lexical environment is also created having the parent function’s lexical environment as parent.

All declarations (function, var, let, const and class) are hoisted in JavaScript, while the var declarations are initialized with undefined, but let and const declarations remain uninitialized. They will only get initialized when their lexical binding (assignment) is evaluated during runtime by the JavaScript engine. This means you can’t access the variable before the engine evaluates its value at the place it was declared in the source code. This is what we call “Temporal Dead Zone”, A time span between variable creation and its initialization where they can’t be accessed.

https://blog.bitsrc.io/hoisting-in-modern-javascript-let-const-and-var-b290405adfda
Bill

Strengthening Memory (Part 3) : Thoughts, Actions and Habits

“Your beliefs become your thoughts,
Your thoughts become your words,
Your words become your actions,
Your actions become your habits,
Your habits become your values,
Your values become your destiny.”

Ghandi

Plasticity means the possession of a structure weak enough to yield to an influence, but strong enough not to yield all at once. Each relatively stable phase of equilibrium in such a structure is marked by what we may call a new set of habits. Organic matter, especially nervous tissue, seems endowed with a very extraordinary degree of plasticity of this sort; so that we may without hesitation lay down as our first proposition the following, that the phenomena of habit in living beings are due to the plasticity of the organic materials of which their bodies are composed.
But the philosophy of habit is thus, in the first instance, a chapter in physics rather than in physiology or psychology.
Water, in flowing, hollows out for itself a channel, which grows broader and deeper; and, after having ceased to flow, it resumes, when it flows again, the path traced by itself before. Just so, the impressions of outer objects fashion for themselves in the nervous system
The only impressions that can be made upon them are through the blood, on the one hand, and through the sensory nerve-roots, on the other; and it is to the infinitely attenuated currents that pour in through these latter channels that the hemispherical cortex shows itself to be so peculiarly susceptible. The currents, once in, must find a way out. In getting out they leave their traces in the paths which they take. The only thing they can do, in short, is to deepen old paths or to make new ones; and the whole plasticity of the brain sums itself up in two words when we call it an organ in which currents pouring in from the sense-organs make with extreme facility paths which do not easily disappear.
If only a part of the matter of the path were to ‘rearrange’ itself, the neighboring parts remaining inert, it is easy to see how their inertness might oppose a friction which it would take many waves of rearrangement to break down and overcome. If we call the path itself the ‘organ,’ and the wave of rearrangement the ‘function,’ then it is obviously a case for repeating the celebrated French formula of ‘La fonction fait l’organe.’
Being physical pathways, the brain needs rest also to form lasting in roads, that is why it is said “we learn to swim in the winter and skate in the summer” There is no part of the organism of ma in which the reconstructive activity is so great, during the whole period of life, as it is in the ganglionic substance of the brain. This is indicated by the enormous supply of blood which it receives. It is moreover, a fact of great significance that the nerve-substance is specially distinguished by its reparative power.
The psychical principles of association, indeed, and the physiological principles of nutrition, simply express – the former in terms of mind,
the latter in terms of brain – the universally admitted fact that any sequence of mental action which has been frequently repeated tends to perpetuate itself; so that we find ourselves automatically prompted to think, feel, or do what we have been before accustomed to think, feel, or do, under like circumstances, without any consciously formed purpose, or anticipation of results. For, when the organic modification has been once fixed in the growing brain, it becomes a part of the normal fabric, and is regularly maintained by nutritive substitution; so that it may endure to the end of life, like the scar of a wound.

William James’ book “Habit”
Bill

strengthening memory (part 1) : practical memory

Forgetting can drive me crazy (literally), but it doesn’t neseccarily mean a physiological or mental issue:orgetting also helps to reconcile the storage of new information with old knowledge.

Memory performance is usually related to the active functioning of three stages. These three stages are:

  1. encoding
  2. storage
  3. retrieval

memory is understood as an informational processing system with explicit and implicit functioning that is made up of a sensory processor, short-term (or working) memory, and long-term memory
Working memory serves as an encoding and retrieval processor.
Explicit and implicit functions of memory are also known as declarative and non-declarative systems.
Declarative, or explicit, memory is the conscious storage and recollection of data.

Under declarative memory resides semantic and episodic memory.
Semantic memory refers to memory that is encoded with specific meaning, while episodic memory refers to information that is encoded along a spatial and temporal plane. Declarative memory is usually the primary process thought of when referencing memory.

Non-declarative, or implicit, memory is the unconscious storage and recollection of information.
An example of a non-declarative process would be the unconscious learning or retrieval of information by way of procedural memory, or a priming phenomenon. Priming is the process of subliminally arousing specific responses from memory and shows that not all memory is consciously activated, whereas procedural memory is the slow and gradual learning of skills that often occurs without conscious attention to learning.

The ways by which information is encoded, stored, and retrieved can all be corrupted.