Data types for JavaScript relearning

Data type classification

basic type

  1. String
  2. Number
  3. Boolean
  4. undefined (indicating that the definition is assigned)
  5. null (indicating the definition and assignment, but the value is null; the initial assignment is null, indicating that the object will be assigned; in addition, re-assigning the object to null can also release the memory occupied by the object)

Reference type

  1. Object : any object
  2. Function : a special object (internally contains executable code)
  3. Array : a special object (with numerical subscripts, internal data is ordered)

Data type judgment

typeof

The return value is the string expression of the data type (lowercase words)
can be judged: undefined / numeric value / string / boolean / function
cannot be judged: null and object, array and object

instanceof

Determine the specific type of object

===

You can directly judge the two types of undefined and null, because both types have only one value.

Variable type

Type of value in variable memory

basic type

The basic type refers to the basic type of data stored in the memory

Reference type

The pointer address is stored in the reference type

Guess you like

Origin blog.csdn.net/qq_43592084/article/details/110202572