April 2018
Beginner
536 pages
13h 21m
English
When we declare a variable in TypeScript, we can use the var, let, or const keywords:
var myNumber: number = 1; let isValid: boolean = true; const apiKey: string = "0E5CE8BD-6341-4CC2-904D-C4A94ACD276E";
Variables declared with var are scoped to the nearest function block (or global, if outside a function block).
Variables declared with let are scoped to the nearest enclosing block (or global, if outside any block), which can be smaller than a function block.
The const keyword creates a constant that can be global or local to the block in which it is declared. This means that constants are block-scoped.