DEV Community

Stefano Armenes
Stefano Armenes

Posted on • Updated on

Another var vs let vs const

During these days I see many articles about this "stuff" declarations war.

I think we can summarise everything in a few lines:

  • var: why? if you can avoid it, do it;
  • prefer const usage if possible of course (together with an immutable approach when updating objects)! But don't be scared using let, especially if the scope of your variables is small, for example inside a function.

Immutable things are cool when they really help, but just keep in mind that (imho) the most important thing is to have maintainable and readable software because we are a community of devs, teammates.

Happy new year! 🎉

Top comments (1)

Collapse
 
sidvishnoi profile image
Sid Vishnoi
var let = "const";
console.log(let);

Sorry 😂