Values, Types and Variables

JavaScript has seven primitive types plus objects, and most beginner bugs come from mixing them up. Learn what each type is, when a value is copied and when it is shared, how var, let and const really differ, and where numbers, strings and null will surprise you.

What you will be able to do

  • Name the eight types and identify any value with typeof and Array.isArray
  • Predict whether a value is copied or shared, and what a function is able to mutate
  • Choose between var, let and const, and explain why const is not immutability
  • Trace hoisting and the temporal dead zone through the creation and execution phases
  • Handle floating point arithmetic, big integers, unicode strings and the null/undefined split

Lessons

  1. The Eight Types — Seven primitives and one object type, and typeof is your first question about any value. (11 min)
  2. Primitives vs References — Primitives are copied. Objects are shared. (12 min)
  3. var, let and const — const locks the label, not the box. (12 min)
  4. Hoisting and the TDZ — Every scope is set up before it runs, but let and const are set up without a value. (11 min)
  5. Numbers and BigInt — Every number is a 64 bit float, so precision is finite and you plan for it. (12 min)
  6. Strings — A string is immutable, so every string method hands you a new string and leaves yours alone. (13 min)
  7. null, undefined and Symbols — undefined is absence that happened to you; null is absence you chose. (9 min)