Simple versus complex types

Simple types are also called primitive data types or value types, and complex types are referred to as reference types.

  • Value types: simple/basic data types. The values themselves are stored in variables when stored, so I am called string, Number, Boolean, underpay, NULL.
  • Reference types: complex types. Only addresses (references) are stored in variables during storage, so they are called reference types. Objects (system objects, custom objects) created by the new keyword, such as Object, Array, Date, etc.

Stack and heap

Stack space allocation difference:

  • Stack (operating system) : The operating system automatically allocates and releases the parameter values of storage functions, local variable values, etc. It operates like a stack in a data structure. Simple data types are stored on a stack.
  • Heap (operating system) : Stores complex types (objects), which are usually allocated and released by the programmer, or collected by the garbage collection mechanism if the programmer does not release them. Complex data types are stored in the heap.