A variable is simply the name of a particular value at a particular point in time.

Graph TD ECMAScript --> ECMAScript --> Undefined --> Null --> Boolean --> Number --> String raw value --> Symbol reference value --> object reference value --> array

The operation primitive value is the direct actual value operation reference is the operation variable reference

Dynamic properties
let a = 'a'; // typeof --> string
let b = new String('b'); // typeof --> objectLog a -->'a'
log b --> 'b'If a.n ame ='A';
b.name = 'B'; The log a.n ame - >undefined
log b.name --> 'B'
Copy the code
let a = {a:1}; // typeof --> object
let b = a; // typeof --> object
typeof a.a; --> number
typeof b.a; --> number

b.a = 2
log a --> {a:2}
log b --> {a:2} because a and b are reference values a.A and b.a refer to the same value. When the value of a.A changes, the value of b.A changes and vice versaCopy the code
let a = 1;
let b = {a:a};
let c = b;
log
    a --> 1
    b --> {a:1}
    c --> {a:1}
    
a = 2;
log
    a --> 2
    b --> {a:1}
    c --> {a:1}
b.a = 2;
log
    a --> 2
    b --> {a:2}
    c --> {a:2}
Copy the code

Stack relationship

Flowchart TB ->a=1 c- >b.a ->b.a ->b.a=1 subgraph; flowchart a["{a:1}"] end subgraph Stack B.a =1[1] A =1[1] end end
Duplicate values
/ / if again
let d = b;
{a:1} in the heap points to d
// When the value changes, it still changes
Copy the code