LET Keyword
The
let
keyword declares a local variable in the block scope. Normally if
statements don’t have scope, but now they do with let
.
This also works for loops too.
for Example :
var x = 1; | |
if(x < 10) { | |
let v = 1; | |
v = v + 21; | |
console.log(v); | |
} | |
console.log(v); //v is not defined |
CONST keyword
A
const
or a constant declaration is where once, the variable is set you can’t change it. It’s read-only.
For example :
const admin = "jain";
admin = "pardeep" //not allowed...readonly
Comments
Post a Comment