A data type
Base type: undefined,null,boolean,number,string save in stack memory space fixed variable accessed directly from the stack memory is the value
Reference type: Array,object,function,regexp save in heap memory takes up space an invariant variable reads a pointer from the stack memory and accesses the value in heap memory through the pointer
1. Dynamic Properties
Cannot add property or method to base type
2. Copying variable values
A value type is a variable of a primitive type, a value that is copied, a variable of a reference type, a copy of a pointer, and the same object that they all point to
3. Parameter passing
All function parameters in ECMAScript are passed by value
functionsetName (obj) {obj.name= "Mysic"; }varperson ={};setname (person); alert (person.name)//Mysic//seems to be a reference. In fact, it is still passed by value. //The value here refers to the pointer that the object holds in the stack memory. functionsetName (obj) {obj.name= "Mysic"; Obj= {}; Obj.say= "BlaBla"; }varperson ={}setname (person); alert (person.name)//MysicAlert (Person.say)//undefined//if it is a reference pass, the person should be the new object in the function and the say property exists. does not actually exist.
4. Detection type
Basic type data with typeof
Reference type data with instanceof Object[,array,regexp]
JavaScript Learning notes-data types