let and var in js code example
Example 1: var vs let js
let: //only available inside the scope it's declared, like in "for" loop,
var: //accessed outside the loop "for"
Example 2: let and var difference
function run() {
var foo = "Foo";
let bar = "Bar";
console.log(foo, bar);
{
let baz = "Bazz";
console.log(baz);
}
console.log(baz); // ReferenceError
}
run();
Example 3: vars with let in it javascript
let /*Var name*/ = /*what is equals*/