JS is a lightweight, weak type of scripting language.
The variables in JS are loosely typed and can store any data type: Basic structure: var variable name = value;
such as: Var num=12; var str= ' month falls silent '; var boo=true; var obj={name: ' Month falls silent '};
var ary=[1,2,3,4]; var reg=/^[0-9]$/; var fn=function () {};
Data types in JS: basic data types and reference data types
Basic data type: consists of simple data segments, including: Number (numeric), string (String), Boolean (True,false), null (NULL), undefined (undefined)
Reference data type: composed of complex data, including object data type, functions (function data type)
Object also contains: Object, Math (mathematical method), string (string method), array (array), REGEXP (Regular), date (Time function)
The principle of reference data type: Define a reference data type, first open a new memory address, and then assign a dummy value to the variable (address, a reference to the newly opened memory space)
such as: obj={name: ' AAA '}
Obj.name= ' BBB '; The new memory space is accessed through the virtual memory address, and the value ' AAA ' of the name attribute in the memory space is changed
Data type detection in JS:
typeof detection data type, returns a string representing the data type
Note: Nan is number type undefined is undefined type
Null is an object type null represents null and is an empty pointer
Objects that are commonly used in TypeOf can only return object and cannot be subdivided into specific
Instanceof is used to detect if an instance belongs to a class.
ToString can subdivide object
Constructor structural function detection
JS data type