Var, Let, Const

Fatima Alam - Dec 1 '23 - - Dev Community

If we declare a variable without any of these keywords -
-> There is a chance that an object with that name is globally declared and now it will try to modify that variable when we were actually originally planning to make a new variable for that code block.

const variables/objects ->
-> Can be treated as fixed values wrapped around with a more handy name.

The difference table

Image description

In a single scope we can declare a variable more than once using var and the last redeclaration takes over the previous ones.
Whereas the let keyword doesn't let a variable name to be redeclared in the same scope so it's more safe.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player