DEV Community

Stefano Armenes
Stefano Armenes

Posted on • Edited on

7 2

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 😂

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

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

Okay