DEV Community

Ali Osaid
Ali Osaid

Posted on

let and Var difference In JavaScript

Lets talk about the difference between Var and let and later on we will talk about what should we use in our JavaScript projects

So Let and Var both use for declaration of variable but there is some difference between them

Let allow us to declare a variable that has limit to the scope of a block statement unlike Var which declares a variable globally or locally to the entire Function;

Now the question is what should we use well we should always use Const if we know the variable value not going to change else we can use Let for declaration ;

Top comments (0)