What Is the Let Keyword in Javascript
Let Allows You to Declare Variables That Are Limited to the Scope of a Block Statement, or Expression on Which It Is Used, Unlike the Var Keyword, Which...
let allows you to declare variables that are limited to the scope of a block statement, or expression on which it is used, unlike the var keyword, which declares a variable globally, or locally to an entire function regardless of block scope.
Should I use let or VAR?
The main difference between the two though is that let deals with block scope whereas var deals with global scope or function scope depending on where it’s declared. As long as your variable isn’t declared within any function, var can be used again anywhere else in your code.
Must Read
Is let used in JavaScript?
The let keyword is used to declare variables in JavaScript. The var keyword can also be used to declare variables, but the key difference between them lies in their scopes. var is function scoped while let is block scoped – we will discuss this in more detail later.