Monday, September 17, 2012

Javascript variable types

Javascript has two kind of variable types.  primitives and references.
Primitives are stored in the stack as we store the actual value of the variable in the memory cell in the stack.  we know its size, it is fixed, no need for dynamic allocation here.
References types of variables are stored in heap and also in stack, in stack we store the the variable heap memory address - the reference as it has a fixed size.  the actual value which is referenced by the stack memory address is the value of the heap address which is dynamic.

No comments: