DEV Community

loading...

Another var vs let vs const

stearm profile image Stefano Armenes Updated on ・1 min read

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! 🎉

Discussion (1)

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

Sorry 😂