1. Stack stack "and heap":Simply put, the memory system allocated on the stack is automatically freed, the memory allocated on the heap is not released, and the memory is there even if the program exits. A stack is typically statically allocated memory, which is typically dynamically allocated on the heap.
2. Basic types and reference types:Basic type: A simple data segment stored in the stack memory. The size of the data determines the amount of memory space that can be allocated. Reference type: An object stored in the heap memory, in which a pointer is actually saved, and the pointer points to another location. Each space size is different, depending on the circumstances of the specific allocation. See the diagram of the Page60 page of JavaScript advanced programming for a clear understanding of the above two concepts.
3. Memory Variable storage space:This is the reason for the JS mechanism to survive. Only by understanding the allocation of this storage space can you better understand JS and write more efficient code.
4. Value passing and reference delivery issues:The value in the former memory does not change, and the value in the latter content changes. The parameters of function () {} functions in JS are interpreted as local variables, which are only useful in function.
5. Execution Environment (SCOPE)1. The execution environment determines the life cycle of the variable, and some code can access the variable's permissions. This mechanism helps when memory is freed. 2. Sub-Global Execution Environment (window) and function execution environment. 3. The local environment of the function can access variables of the functional scope and have access to the variable 4 in the containing (parent) environment. The Global environment cannot access variables in the function environment.
6.JS is a language with an automatic garbage collection mechanismWe're not thinking about memory allocation and recycling issues, unlike C + +
JavaScript stacks and heap memory, scope