a basic data type
Basic data types are simply simple data segments.
Reference types are objects composed of multiple values.
When we perform an assignment operation, the parser will first analyze whether the data is a value type or a reference type.
There are 6 basic data types: String, number, null, undefined, boolean, symbol
These six basic data types can directly manipulate the actual value stored in the variable
var a = 10;
var b = a;
b = 20;
console.log(a);
Let's do a simple assignment operation below,
1. First Numbers are Basic Data Types
2. var b = a, this assignment operation actually copies the data of a and assigns it to b
3. a and b are completely independent
4. b = 20 modifies the value of b will not affect the value of variable a
5. Common types are stored in stack memory
Two reference data types
In js, reference type data is stored in heap memory, but it is not possible to directly access the location in the memory space and operate the heap memory space
Only through the reference address in the stack memory of the operation object. Therefore, the data of the reference type is actually stored in the stack memory and the object is stored in the corresponding memory.
reference address. Use this reference address to quickly find objects stored in heap memory. 4
var obj1= new Object();
var obj2 = obj1;
obj2 = 'lele';