const in javascript It prints 2. Even though we used const. Most developers think const means unchangeable. So when an object’s property updates successfully, it feels wrong. Like JavaScript ignored its own rule. But it didn’t. const prevents reassignment. It doesn’t freeze the value inside. The variable is locked. The object it points to isn’t. This subtle distinction causes real confusion in frontend development, interviews, and production code. Understanding reference vs value is one of those JavaScript quirks that separates confidence from correctness. If you're learning clean JavaScript, debugging tricky behavior, or preparing for JavaScript interview concepts, this is foundational. Follow CodeBreakDev for code that looks right… but isn’t.

To view or add a comment, sign in

Explore content categories