Variables
- Variables don’t have types in JavaScript — only values do.
- Primitive Values Are Immutable
- 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
console.log(typeof(null)); // "object" (a lie!)
Count
undefined
only onenull
only oneboolean
true and false, only two
remember the numbers when you draw the stars.
NaN===NaN
//false, but Object.is(NaN, NaN) // true0===-0
// true, but Object.is(0, -0) //falseObject.is
perfectly matches the mental modal of thinking of values as stars, but===
has the above two exceptions.