Types

  • 1.1 Primitives: When you access a primitive type you work directly on its value.

    • string
    • number
    • boolean
    • null
    • undefined
    • symbol

      1. const foo = 1;
      2. let bar = foo;
      3. bar = 9;
      4. console.log(foo, bar); // => 1, 9
    • Symbols cannot be faithfully polyfilled, so they should not be used when targeting browsers/environments that don’t support them natively.

  • 1.2 Complex: When you access a complex type you work on a reference to its value.

    • object
    • array
    • function

      1. const foo = [1, 2];
      2. const bar = foo;
      3. bar[0] = 9;
      4. console.log(foo[0], bar[0]); // => 9, 9