the fourth chapter of the advanced programming of JavaScript reading notes4.1 values for base types and reference types1. The base type values are: Undefined, Null, Boolean, number, and String. Reference type values refer to objects that may consist of multiple values. "Note: The string is not a reference type of" 2. The base type occupies a fixed amount of space in memory and is therefore stored in the stack memory. The value of a reference type is an object that is saved in heap memory. "The access address of an object is stored in the stack memory, but the value of the object is allocated by heap memory" "because the size of the object's values is not fixed, they cannot be saved to the stack memory. However, the memory address size is fixed, so the grams memory address size is stored in the stack memory. "3. Copying the value of a reference type from one variable to another is actually a pointer, so two variables end up pointing to the same object. 4. Determine which base type a value is available with the TypeOf operator, and determine which reference type can use the instanceof operator. 5. The parameters of all functions in the ECMAScript arePass by ValueOf
related article: JavaScript variable--stack memory or heap memory (HTTP://WWW.TUICOOL.COM/ARTICLES/M2QUEQ)
4.2 Execution Environment and scope1. The execution environment has a global execution Environment (Global environment) and a function execution environment. 2. Each time you enter a new execution environment, you will create a scope chain for searching for variables and functions. 3. The execution environment of variables helps determine when memory should be freed. 4. In strict mode, initializing undeclared variables results in an error. 5. The execution environment determines the life cycle of the variable. 4.3 garbage collection1. JavaScript is a programming language with an automatic garbage collection mechanism, and developers do not have to care about memory allocation and recycling issues. 2. Values leaving the scope are automatically marked as recyclable and therefore will be deleted during garbage collection. 3. "Tag Cleanup" is currently the mainstream garbage collection algorithm, the idea is to add tags to the currently unused values, and then reclaim their memory. 4. The other is "reference counting". The reference count algorithm causes problems when there is a circular reference phenomenon in your code.
JavaScript variables, scopes, and memory issues