Variables in JavaScript: var, let, const Explained

🚀 Day 2/108 – Variables in JavaScript (var, let, const) Continuing my 108-day JavaScript journey — today I learned about variables 👇 👉 What are Variables? Variables are containers used to store data values in a program. In JavaScript, we mainly use 3 types: var, let, and const 🔹 var • Old way of declaring variables • Function scoped • Can be re-declared and updated 🔹 let • Block scoped • Can be updated but not re-declared in the same scope 🔹 const • Block scoped • Cannot be updated or re-declared • Must be initialized when declared 💻 Example: var name = "John"; let age = 22; const country = "India"; age = 23; // allowed // country = "USA"; ❌ not allowed 🧠 Key Insight: Always prefer let and const over var in modern JavaScript. 🔥 Learning step by step — consistency is the key! Are you using var, let, or const in your projects? 👇 #JavaScript #WebDevelopment #CodingJourney #LearningInPublic #108DaysOfCode

  • graphical user interface

To view or add a comment, sign in

Explore content categories