⚡ Tip: const Doesn’t Mean “Constant” in JavaScript
🚀 Aspiring Full-Stack Developer Blogger 👨💻 Passionate about web development and coding. ✍️ Sharing my journey through tech via CodeOdyssey 🌍 "The code is a journey, not a destination."
Many beginners assume:
"
constmeans the value can never change."
But that’s not exactly true.
✅ What const Really Means
constprevents reassignment of the variable identifier.It doesn’t make the value itself immutable.
Example:
jsCopyEditconst user = { name: "Nora" };
user.name = "Lina"; // ✅ This works!
But:
jsCopyEdituser = { name: "Ali" }; // ❌ Error: Assignment to constant variable
🔐 If You Want to Freeze the Value
Use Object.freeze():
jsCopyEditconst settings = Object.freeze({ darkMode: true });
settings.darkMode = false; // ❌ No effect
Note: Object.freeze() is shallow — it won’t freeze nested objects.
🧠 Quick Recap
| Keyword | Reassign? | Mutable? |
var | ✅ | ✅ |
let | ✅ | ✅ |
const | ❌ | ✅ (unless frozen) |
💡 Pro Tip: Use const by default. Only use let when reassignment is needed.

