- A variable is a named box that holds a value.
- Create variables with
let(can change) orconst(locked, can't be reassigned). - Use
constby default, andletonly when the value needs to change. varis the old way. Recognize it, but don't use it in new code.=is the assignment operator. It means "put into," not "equals."- Only use
letorconstthe first time. To change aletvariable, just use its name. - Variable names use camelCase, can't start with a digit, can't contain spaces or hyphens, and can't be reserved words.
- A variable with no value contains
undefined. Using a variable that doesn't exist at all gives a ReferenceError. - JavaScript works out the right side of
=first, soscore = score + 10means "add 10 to whatever's in score."
Reading is step one
CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.