DEV Community

loading...

Discussion on: Demystifying "const" variables in JavaScript

Collapse
nickytonline profile image
Nick Taylor (he/him)

I use const all the time. It's very rare that I need let. I can see let being used as an index in a for loop, but I almost never need a for loop. Filter, map and reduce usually do the trick.

Collapse
sunnysingh profile image
Sunny Singh Author

We're in the same boat! I try to avoid let and even loops, which people think I'm crazy for.

Collapse
georgecoldham profile image
George

Map, Filter and Reduce are loops, but they are immutable for the purpose of us devs.

Thread Thread
sunnysingh profile image
Sunny Singh Author

They're declarative loops, but yes definitely loops.

Collapse
georgecoldham profile image
George

Functional and immutable Js makes code more readable and maintainable imo. I almost exclusively use const, I have yet to find a scenario where I need to change this.