js let code example
Example 1: javascript var let
function func(){
if(true){
var A = 1;
let B = 2;
}
A++;
B++;
return A + B;
}
Example 2: var vs let js
let:
var:
Example 3: let in javascript
The let statement declares a block scope local variable, optionally initializing it to a value.
let x = 1;
if (x === 1) {
let x = 2;
console.log(x);
}
console.log(x);
Example 4: let javascript
The let statement declares a block-scoped local variable,
optionally initializing it to a value.
let x=1;
Example 5: vars with let in it javascript
let =
Example 6: let javascript
var i = "global";
function foo() {
var i = "local";
console.log(i);
}
foo();
console.log(i);