This statement assists a user in declaring any local variable in a TypeScript. The var keyword is similar to the let keyword, but there are some restrictions in the let keyword as compared to the var keyword. It can easily enhance the readability of the code, and it decreases the overall chances of running a programming error. Any variable that we declare using the let keyword stays limited only to the block-scoped.
Note – The major difference between let and var is not present in the syntax. They both rather differ in the semantics.
|The var keyword has a global scope.
|The let keyword stays limited to the block scope.
|Access and Declaration
|One can easily declare as well as access it globally.
|One can easily declare it globally but can’t access it globally.
|We can re-declare any variable that we declare using the var keyword, and we can also update it in the very same scope.
|We can upload any variable that we declare using the let keyword but not re-declare it in the very same scope.
Keep learning and stay tuned to BYJU’S to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2024, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cutoff, GATE Previous Year Question Paper, and more.