what is the difference between let and const in typescript code example
Example 1: what is the difference between let and const in javascript
The difference is that with const you can only only assign a value to a variable
once, but with let it allows you to reassign after it has been assigned.
Example 2: var vs let vs const typescript
let num1:number = 1;
function letDeclaration() {
let num2:number = 2;
if (num2 > num1) {
let num3: number = 3;
num3++;
}
while(num1 < num2) {
let num4: number = 4;
num1++;
}
console.log(num1);
console.log(num2);
console.log(num3);
console.log(num4);
}
letDeclaration();