• Basic data types (value types)

    • Value type Because the structure is relatively simple, the value created directly into the “stack memory”, so the stack memory has two functions: 1. For code to execute. 2. Store basic type values
  • Reference data types (object functions)

    • The structure of a reference data type is relatively complex (a complex, containing many values) and cannot be stored directly in stack memory. Instead, it needs to be stored in a separate space called “heap memory”. Reference data types are stored in a separate “heap memory”.
    • Heap memory serves only one purpose: to store values of reference types
About the differences between data types

Object [attribute name] = attribute value (Attribute name is a concrete value, and if it is an object, it is converted to a string) Attribute names in an object cannot be repeated, and the same number and string count as the same attribute eg: Obj [0] === obj[‘0’] === obj[‘0’] === obj[‘0’] === obj[‘0’] === obj[‘0’]

let a = {}, b = '0', c = 0; A [b] = 'George '; A [c] = 'p '; console.log(a[b]); We're looking at the same propertyCopy the code
let a = {}, b = Symbol('1'), c = Symbol('1'); A [b] = 'George '; A [c] = 'p '; console.log(a[b]); The Symbol is the unique value for the different properties examined. The two symbols are not equal. Here are two attributes Symbol (' 1 '). The toString () = = = Symbol (' 1 '). The toString () / / true Symbol (' 1 ') = = = Symbol (' 1 ') / / falseCopy the code
let a = {}, b = { n: '1' }, c = { m: '2' }; A [b] = 'George '; A [c] = 'p '; console.log(a[b]); The property name cannot be an object, the object needs to be converted to a bit stringCopy the code