JS knowledge 1

1. Why does null use typeof to detect Object? :

  • All data type values stored in the computer are “binary”
  • null -> 000000
  • Everything starts with 000
  • When TypeOF checks, it checks against the binary values stored on the computer

2. Data types in js

  • Basic data types (value types, primitive types)
    • number
      • NaN
      • Infinity
    • string
    • boolean
    • null
    • undefined
    • Symbol(symbol () unique value, not new)
      • static Symbol
      • Symbol.prototype
    • Bigint (Large number (used when number exceeds +(-)2^53 maximum security number) => + n after number)
  • Reference data type
    • object
      • Ordinary objects
      • The array object
      • Regular object
      • The date object
      • JSON
      • Set
      • Map
      • .
    • function
      • Common function
      • The constructor
      • Arrow function
      • Generator function
      • .

3. JS code running environment

  • The browser
  • node
  • webview
  • .

(When the browser runs JS code, it allocates a Stack in the computer’s memory for the code to execute.)

Var = [value]

  • Create a value first:

    • Base data type value, directly stored in the stack memory
    • Reference data to create a separate time space (the Heap memory) for storing values
  • Place a variable object in the current context (VO/AO)

  • Associate variables with values (assign defined)