Theoretical recap.
In JavaScript ES6+, you declare variables mainly with two keywords: let and const.
Use const when a value must not be reassigned after its initial assignment, and let when the value may change over time.
Avoid the older var, which behaves inconsistently due to function scoping and hoisting.
A useful mental model: A variable is a labeled box that holds a value.
With const, the label is glued permanently to one box.
With let, you can move the label to another box later.
JavaScript has primitive types you already covered: string, text in quotes; number, integers and decimals; boolean, true/false; undefined, declared but not assigned; and null, intentional absence of value.
To inspect a value's type, use the typeof operator.
To display values, you have two common tools.
Console.log prints to the browser or node console and is your primary debugging tool.
Document.write or DOM manipulation prints to the page, but for now focus on console.log. Mini example.
Const firstName = "Ada" let age = 36. console.log(firstName, age, typeof age).
Common mistakes: Reassigning a const throws an error.
Confusing equals, assignment, with equals equals or equals equals equals, comparison.
Forgetting quotes around strings so JavaScript treats text as an undefined variable, and mixing up null with undefined.
Keep your naming clear and consistent using camel case.
Read the full transcript.
Create an account to read the whole episode, search across every transcript, and follow the shows you care about.
Theoretical recap.
In JavaScript ES6+, you declare variables mainly with two keywords: let and const.
Use const when a value must not be reassigned after its initial assignment, and let when the value may change over time.
Avoid the older var, which behaves inconsistently due to function scoping and hoisting.
A useful mental model: A variable is a labeled box that holds a value.
With const, the label is glued permanently to one box.
With let, you can move the label to another box later.
JavaScript has primitive types you already covered: string, text in quotes; number, integers and decimals; boolean, true/false; undefined, declared but not assigned; and null, intentional absence of value.
To inspect a value's type, use the typeof operator.
To display values, you have two common tools.
Console.log prints to the browser or node console and is your primary debugging tool.
Document.write or DOM manipulation prints to the page, but for now focus on console.log. Mini example.
Const firstName = "Ada" let age = 36. console.log(firstName, age, typeof age).
Common mistakes: Reassigning a const throws an error.
Confusing equals, assignment, with equals equals or equals equals equals, comparison.
Forgetting quotes around strings so JavaScript treats text as an undefined variable, and mixing up null with undefined.
Keep your naming clear and consistent using camel case.