How Does JavaScript Math?
summary
Explains why + sometimes concatenates and sometimes adds by walking actual examples, console experiments, and the ECMAScript rules: ToPrimitive and defaultValue force objects to strings for addition, arrays coerce to comma-joined strings, and unary plus always casts to Number. Demonstrates that {} can parse as an empty block ambiguity, causing surprising zero results, and verifies that subtraction/multiplication/division always coerce to Number. Builds a simple model, tests it in a REPL, and checks the spec to confirm it works.
AI-written summary · about
chapters (5)
related talks
20mJavaScript’s “+” Operator and Decision Fatigue
05mJavaScript: The Bad Parts
23mTruthiness, falsiness and other JavaScript gotchas
32mJavaScript is weird. MythBusters special
18mWTFJS
41mJavaScript is Weird. MythBusters Special
36mJavaScript Puzzlers
27mEverything you never wanted to know about JavaScript numbers
