The data types in JS are generally divided into two categories, namely: 1value type(base type): Numeric type (number), character type (String), Boolean (Boolean), NULL, and UNDERFINED2Reference type(Class): Functions, objects, arrays, etc.Value type Understanding: The reciprocal assignment of variables,is to open up a new memory space, assign the value of the variable to the new variable and save it in the newly opened memory.After that, the value changes of the two variables do not affect each other; for example: Var a=10;//opens up a memory space to hold the value of variable a "ten"; var b=a;//a new memory space for variable B, saving a value of "10" to the new memory; the value of//a and B changes anyway, Will not affect the value of each other;Reference type Understanding: The mutual assignment of variables, just the exchange of pointers, rather than the object (ordinary object, function object, array object) Copy to a new variable, the object is still only one, just a guide ~ ~; for example: Var a={x:1,y:2}//need to open up memory space to save objects, The value of variable A is an address that points to the space where the object is saved, and VAR b=a;//assigns a guideline address to B, rather than copying a given object and a new memory space to save;//This time through a to modify the properties of the object, then through B to view the properties of the object property has changed; JS Interpreter has its own memory management mechanism, when there is no longer any one reference to an object, the interpreter will consider this object useless, and then recycle the memory resources occupied by this object, the value types are objects (except null and underfined), but they arePseudo-ObjectObjects/pseudo-objects have properties and methods; ECMAScript specifies that all objects have the ToString () method, either an object or a pseudo object; The original/default type of the Number,string,boolean value is a pseudo-object; they all have attributes. Both have the ToString () method; null and underfined have no properties and methods;
JS two types of data