1️⃣ Variables in JavaScript
Variables store data. In modern JS, we use
let and const.let age = 25; // Can be changed
const name = "Riya"; // Cannot be changed
📝 Use
let when the value will change, const when it won’t.2️⃣ Data Types
JavaScript is dynamically typed.
let name = "John"; // String
let age = 30; // Number
let isOnline = true; // Boolean
let score = null; // Null
let x; // Undefined
let user = {name: "Ali"}; // Object
let colors = ["red", "blue"]; // Array
3️⃣ Type Checking
console.log(typeof age); // "number"
console.log(typeof name); // "string"
4️⃣ Operators in JavaScript
Arithmetic Operators:
let x = 10, y = 3;
console.log(x + y); // 13
console.log(x % y); // 1
console.log(x ** y); // 1000
Assignment Operators:
x += 5; // same as x = x + 5
x *= 2;
Comparison Operators:
console.log(x > y); // true
console.log(x === 10); // true
console.log(x !== y); // true
Logical Operators:
let a = true, b = false;
console.log(a && b); // false
console.log(a || b); // true
console.log(!a); // false
✅ Practice Task:
1. Create 3 variables:
name, age, isStudent 2. Print them using
console.log() 3. Use arithmetic operators to perform basic math
4. Try
typeof on each variable 💬 Tap ❤️ for more!