The data type

  • classification
  • judge

classification

  • Basic (value) types
  • Object (reference) type

Base value type

  • String Any String
  • Number Indicates an arbitrary Number
  • boolean true/flase
  • undefined undefined
  • null null

Object (reference) type

  • Object Any Object
  • Function a special object (that can be executed)
  • Array A particular type of object (numeric subscript, internal data ordered)

judge

  • typeof
    • Returns a string representation of the data type
    • Can judge undefined
    • You can determine the value
    • Can be used to determine the string
    • Boolean values can be determined
    • Function
    • Null and object cannot be determined
    • Object and array cannot be determined
  • instanceof
    • Determine the specific type of the object
    • You cannot judge undefined
    • The other two will do
  • = = =
    • Judge undefined
    • Determine the null

The problem

1. Undefined is null.

  • Undefined means the definition has no value assigned
  • Null is defined and assigned, but the value is null

2. When is a variable assigned to null?

  • Initial assignment, indicating that an object will be assigned
  • Before you finish, make the object a garbage object (to be collected by the garbage collector)

3. Strict distinction between variable types and data types?

  • Type of data
    • Basic types of
    • Object type
  • Type of variable (variable memory value type)
    • Basic type: Save data that is the basic type
    • Reference type: Holds the address value

The instance

  • Instance: Instance object
  • Type: Type object

data

Question: when a variable parameter is passed in a JS call, is it passed by value or by reference

How does the JS engine manage memory

  • 1. Memory life cycle
    • Allocate a small memory space and get the use of it
    • Stores data and can be manipulated repeatedly
    • Free up small memory space
  • 2. Release memory
    • Local variables: the function is automatically released after execution
    • Object: become garbage object ==> garbage collector collection