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)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay