A 1.ECMAScript variable may contain values for two different data types: a base type value and a reference type value. In many languages, strings are represented in the form of objects and are therefore considered reference types, and ECMAScript abandons this tradition.
2. Copy the value of the base type from one variable to another, creates a new value on the variable object, and then copies the value to the location assigned to the new variable, and the two variable value operations do not affect each other .
3. When copying the value of a reference type from one variable to another, the value stored in the variable object is copied into the space allocated for the new variable, but the copy of the value is actually a pointer to an object stored in the heap, and after copying, two Variables point to the same object, and the actions affect each other .
All functions in 4.ECMAScript are passed by value .
5.instanceof is commonly used to detect the type of object. The values of all reference types are instances of object.
6. In a Web browser, the Global execution Environment is considered a Window object , so all global variables and functions are created as properties and methods of the Window object. The global execution environment is not destroyed until the application exits-when the Web page or browser is closed. Each function has its own execution environment. The relationships between environments are linear in order and can only be searched up for variables and functions in the external environment, and cannot search down variables and functions in the internal environment.
7. variables declared with Var are automatically added to the closest environment , and if the variable is initialized without a var declaration , the variable is automatically added to the Global environment .
8. Once the data is no longer useful, it is a good idea to release its reference by setting its value to null to free up memory space.
9. The base type value occupies a fixed amount of space in memory, so it is stored in the stack memory , and the value of the reference type is an object of an invariant size, stored in heap memory.
JavaScript Learning Note Five: variables, scopes, and memory issues