DEV Community

Cover image for The Secret Life of JavaScript: Let, Const, and Why Variables Are Complicated

The Secret Life of JavaScript: Let, Const, and Why Variables Are Complicated

Aaron Rose on December 08, 2025

Chapter 1: Three Keys to the Kingdom Timothy stared at his browser console in complete confusion. He'd written what seemed like simple J...
Collapse
 
sunilfromqvista profile image
Sunil Goyal

Interesting questions! Playing around with let and const reminded me how important clear structure and encapsulation are — something we focused on while building QVista to make workflow automation visual, organized, and easy to manage.

Collapse
 
xwero profile image
david duymelinck

The use of const, let and var in the post is the common agreement in the community.
I think the biggest pain point is the use of const. While it is a constant for primitives like strings and floats, when you are using it on arrays of objects it is not that much of a constant.

For me working with objects or arrays I use let when the variable should not be exposed. Otherwise I use var.

The reason block scopes are safer from overwriting has to do with the fact that javascript has no namespacing build in. The emulation of namespaces is nesting variables in objects.

Collapse
 
aaron_rose_0787cc8b4775a0 profile image
Aaron Rose

Thanks David! You've identified the issue that trips people up—const protects the binding, not the contents. Your point about arrays and objects is perfect. The namespacing insight about block scope is excellent too—that's the real nice thing with let and const. Cheers buddy! ❤

Collapse
 
chizihn profile image
Chizi

Cool article

Collapse
 
aaron_rose_0787cc8b4775a0 profile image
Aaron Rose

Thanks Chizi. Have a good one! ❤️

Collapse
 
kaike_m profile image
Kaike Maróstica

Nice article! Very well explained and detailed information

Collapse
 
cristea_theodora_6200140b profile image
Theodora Cristea • Edited

Very well expleined! Congrats!👏👏👏

Collapse
 
aaron_rose_0787cc8b4775a0 profile image
Aaron Rose

Thanks Theodora. Cheers!

Collapse
 
rishit537 profile image
Rishit Shukla

Great explanation! 👏

Collapse
 
aaron_rose_0787cc8b4775a0 profile image
Aaron Rose

Thank you, Rishit. Cheers! ❤

Collapse
 
abhinavshinoy90 profile image
Abhinav Shinoy

Neatly written

Collapse
 
aaron_rose_0787cc8b4775a0 profile image
Aaron Rose

thanks! cheers Abhinav ❤

Collapse
 
fralau profile image
Laurent Franceschetti

Thanks for this clarification!

Collapse
 
aaron_rose_0787cc8b4775a0 profile image
Aaron Rose

My pleasure, Laurent! I'm glad it landed clearly. This series is all about making the confusing parts of JavaScript actually make sense. More chapters coming on this, prototypes, and the event loop. Thanks for reading! ❤