Difference between using “let” and “var”?
let keyword was introduced in the ES6. Main difference is scoping rules. Variables declared by var keyword are scoped to the immediate function body (hence the function scope) while let variables are scoped to the immediate enclosing block denoted by { } (hence the block scope). The reason why let keyword was…