Variables and types
Goal: Annotate values and let the compiler catch mismatches.
Use const by default; let when reassignment is required. Primitives: string, number, boolean.
Example
const pi: number = 3.14
let count: number = 0
count = count + 1
const label: string = "items"
const ok: boolean = count > 0Key takeaways
constbindings cannot be reassigned.- Annotations are optional when inference is obvious.
- SJS-E001 fires on type mismatches.
Next: Functions