TypeScript: Scope
let n: number = 1;
if(true){
console.log(n); // === 1
}
console.log(n); // === 1let n: number = 1;
if(true){
if(true{
console.log(n); // === 1
}
}
console.log(n); // === 1if(true){
let n: number = 1;
console.log(n); // === 1
}
console.log(n); // ERRORLast updated
Was this helpful?