Variables

  • Variables don’t have types in JavaScript — only values do.
  • Primitive Values Are Immutable

image.png

  • Variables are not values, variables point to values.
  • The left side of an assignment must be a “wire”
  • The right side of an assignment must be an expression, variable is an expression too.

**y = x** 并不是将变量x赋值给y,而是将expression x 所指向的value赋值给变量 y

  • null is primitive, even though typeof prints object, which is a bug of typeof
    1. console.log(typeof(null)); // "object" (a lie!)

Count

  • undefined only one
  • null only one
  • boolean true and false, only two

remember the numbers when you draw the stars.
image.png
image.png

  • NaN===NaN //false, but Object.is(NaN, NaN) // true
  • 0===-0 // true, but Object.is(0, -0) //false

    Object.is perfectly matches the mental modal of thinking of values as stars, but === has the above two exceptions.