call by reference: dereference occurs automatically for assignment, so that the object pointed to by the reference is changed, the reference address in the variable stays the same

call by sharing: (call by value where the value is a reference, call by object, call by object sharing), no automatic dereference for assignment, assignment will simply assign to the variable containing the reference address whatever that you're trying to assign it. "Automatic" (signaled by syntax, like obj.field) dereference occurs only when using the variable containing the reference address to access or change the field of the caller's object.

For functional programming, why is loop not allowed? why do we care if the counter is mutable if the counter can't be seen outside the function.

JavaScript is a lexically scoped language: the scope of a variable can be thought of as
the set of source code lines for which the variable is defined. Global variables are defined
throughout the program. Local variables are defined throughout the function in which
they are declared, and also within any functions nested within that function.

In some C-like programming languages, each block of code within curly braces has its
own scope, and variables are not visible outside of the block in which they are declared.
This is called block scope, and JavaScript does not have it. Instead, JavaScript uses
3.10 Variable Scope | 53
Core JavaScript
function scope: variables are visible within the function in which they are defined and
within any functions that are nested within that function.

Closures are easy to understand if you simply accept the lexical scoping rule: functions
are executed using the scope chain that was in effect when they were defined.

A1

In computer science, and more specifically in computability theory and computational complexity theory, a model of computation is a model which describes how a set of outputs are computed given a set of inputs. This model describes how units of computations, memories, and communications are organized. The computational complexity of an algorithm can be measured given a model of computation. Using a model allows studying the performance of algorithms independently of the variations that are specific to particular implementations and specific technology.

Sequential models include:

Finite state machines

Pushdown automata

Turing Machine

Functional models include:

Lambda calculus

Recursive functions

Combinatory logic

Cellular automaton

Abstract rewriting systems

Concurrent models include:

Kahn process networks

Petri nets

Synchronous Data Flow

Interaction nets

There are many models of computation, differing in the set of admissible operations and their computations cost. They fall into the following broad categories: abstract machine and models equivalent to it (e.g. lambda calculus is equivalent to the Turing machine), used in proofs of computability and upper bounds on computational complexity of algorithms, and decision tree models, used in proofs of lower bounds on computational complexity of algorithmic problems.

A2

Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithm, in the sense that a function is computable if there exists an algorithm that can do the job of the function, i.e. given an input of the function domain it can return the corresponding output. Computable functions are used to discuss computability without referring to any concrete model of computation such as Turing machines or register machines. Any definition, however, must make reference to some specific model of computation but all valid definitions yield the same class of functions. Particular models of computability that give rise to the set of computable functions are the Turing-computable functions and the μ-recursive functions.

A3

Computability theory, also known as recursion theory, is a branch of mathematical logic, of computer science, and of the theory of computation that originated in the 1930s with the study of computable functions and Turing degrees. The field has since expanded to include the study of generalized computability and definability. In these areas, recursion theory overlaps with proof theory and effective descriptive set theory.

Basic questions addressed by recursion theory include:

What does it mean for a function on the natural numbers to be computable?
How can noncomputable functions be classified into a hierarchy based on their level of noncomputability?