Main content:
- Understanding the values of basic types and reference types
- Understanding the execution Environment
- Understanding Garbage Collection
4.1 Values for base types and reference types
A primitive type value refers to a simple data segment, whereas a reference type value refers to an object that may consist of multiple values. When assigning a value to a variable, the parser must determine whether the value is a base type value or a reference type value.
4.1.1 Properties of the dynamic
For values of reference types, we can add properties and methods to them, and you can change and delete their properties and methods.
4.1.2 Copy variable values
var num1=5;
var num2=num1;
The NUM1 and the 5 in num2 are respectively preserved and independent of each other.
var obj1=new Object ();
var obj2=obj1;
Obj1.name= "Hello";
alert (obj2.name);//"Helo"
Obj1,obj2 is applied to the same object object.
4.1.3 Passing parameters
The parameters of all functions in ECMAScript are passed by value.
4.1.4 Detection Type
JavaScript variables, scopes, and memory issues