Day 1: JavaScript Variables and Data Types Explained Simply
Learn how JavaScript stores and handles data, The foundation of every web app.

Here’s a clean non-bullet, blog-friendly “About Me” for your Hashnode page: I’m a Frontend Developer based in Pune with experience in Angular, TypeScript, JavaScript, HTML, and CSS. I enjoy building clean, scalable interfaces and working on products like dashboards, ERP systems, and B2B platforms. My focus is on writing maintainable code, improving performance, and creating user-friendly experiences. I also explore concepts around UI architecture, component patterns, and frontend best practices, which I document and share through my blogs. My goal is to create helpful, practical content for developers who are learning and building real-world projects.
What is JavaScript?
JavaScript (JS) is a computer language that makes web pages interactive.
It helps you add things like buttons that work, forms that respond, and animations that move.
While HTML builds the structure and CSS makes it look good, JavaScript makes it come alive.
Example
<button> Click me! </button> <!-- Without JavaScript -->
<button onclick="alert('Hello, World!')"> Click me!</button> <!-- With JavaScript -->
JavaScript is what turns a static webpage into an interactive experience from buttons and popups to real-time apps and games.
Variable
A variable is like a container that holds data.
You can store, use, and change values inside it anytime.
Variables in JavaScript are like water bottles they hold something, but not all bottles behave the same.
Var : The Leaky Bottle
You can pour out the water, fill it again, and even spill it everywhere.
It doesn’t care where it leaks, that’s why it’s not safe to use anymore.
var is the old way to declare variables in JavaScript.
You can change its value and even re-declare it.
It does not follow block rules, so it can leak outside { }.
Example :
var bottle = "Water";
bottle = "Juice";
console.log(bottle); // Juice
var city = "Pune";
var city = "Delhi"; // ✅ works
console.log(city); // Delhi
let : The Refillable Bottle
You can change what’s inside, but it stays sealed inside one place (your block).
If you put it somewhere else, it won’t spill over.
let is the modern way to declare variables.
You can change its value, but cannot re-declare it in the same block.
It follows block scope, meaning it stays inside { }.
Example :
let drink = "Coffee";
drink = "Tea";
console.log(drink); // Tea
let age = 25;
age = 26; // ✅ works
let age = 30; // ❌ Error
const : The Sealed Bottle
Once sealed, you can’t change what’s inside.
It’s frozen — permanent — like bottled soda you can’t refill.
const is used when you don’t want the value to change.
You must assign a value when declaring it, and it can’t be changed or re-declared.
Example :
const soda = "Coke";
soda = "Pepsi"; // ❌ Error
const country = "India";
country = "USA"; // ❌ Error
In short:
Use
letfor changing valuesUse
constfor fixed valuesAvoid
varin modern JavaScript
varleaks,letkeeps,constlocks.
Data Types in JavaScript
A data type means what kind of value a variable holds.
Think of it like “what’s inside your box.
| Data-Type | Description | Example |
| String | Anything inside " " or ' ' is a string. | let name = "Adiba"; |
| Number | All numbers | let age = 25; let price = 99.99; |
| Boolean | true or false | let isOnline = true; let isAdmin = false; |
| Array | list of values | let skills = ["HTML", "CSS", "JavaScript"]; |
| Object | data with labels | let user = { name: "Adiba", city: "Pune", age: 25 }; |
| Undefined | declared but not given a value | let country; |
| Null | empty on purpose | let car = null; |
🧠 Task
1) Write a short script that prints:
One leaky bottle (var)
One refillable bottle (let)
One sealed bottle (const)
Then change their values and observe what happens in the console.
2) Make one variable for each data type and print all of them in one console statement.
Example:
console.log(name, age, isOnline, skills, user, country, car);
🚀 Coming Up Next
Tomorrow → Day 2: Functions and Arrow Functions
We’ll teach JavaScript to think and repeat actions with reusable code.