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
typeofandArray.isArray - Predict whether a value is copied or shared, and what a function is able to mutate
- Choose between
var,letandconst, and explain whyconstis 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
- The Eight Types — Seven primitives and one object type, and
typeofis your first question about any value. (11 min) - Primitives vs References — Primitives are copied. Objects are shared. (12 min)
- var, let and const —
constlocks the label, not the box. (12 min) - Hoisting and the TDZ — Every scope is set up before it runs, but
letandconstare set up without a value. (11 min) - Numbers and BigInt — Every
numberis a 64 bit float, so precision is finite and you plan for it. (12 min) - Strings — A string is immutable, so every string method hands you a new string and leaves yours alone. (13 min)
- null, undefined and Symbols —
undefinedis absence that happened to you;nullis absence you chose. (9 min)