What is the difference between let, var, and const? In this article, I’m explaining the importance of these three keywords in JavaScript and TypeScript . I also provided various examples to deeply understand and use them and what happened when? Let see about: V ar vs. Let vs. Const var : - 1. var is function-scoped 2. var return undefined when accessing a variable before it's declared let : - 1. let is block-scoped 2. let throw ReferenceError when accessing a variable before it's declared const :- 1. Const is block-scoped 2. Const throw ReferenceError when accessing a variable before it's declared 3. Const cannot be reassigned Let see the Examples to understand what happens when - What will happen when the following ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers