✅ JavaScript Fundamentals
📌 Variables, Data Types, Operators
❓ What JavaScript is
- JavaScript makes web pages interactive
- Runs in the browser
- Controls logic and behavior
HTML → structure
CSS → design
JavaScript → brain
📦 Variables (Storing data)
Variables store values in memory.
Three ways to declare variables:
🔹 let
• Value can change
• Block scoped
• Most commonly used
🔹 const
• Value cannot be reassigned
• Used for fixed values
🔹 var
• Old style
• Function scoped
• Avoid in modern JS
Example:
let age = 25;🧾 Data Types in JavaScript
const name = "Deepak";
JavaScript is dynamically typed.
🔢 Number
let score = 90;📝 String
let city = "Delhi";✅ Boolean
let isLoggedIn = true;📦 Undefined
let x;🚫 Null
let data = null;🧠 Object
let user = { name: "Amit", age: 30 };📚 Array
let skills = ["HTML", "CSS", "JS"];➕ Operators Explained
🔹 Arithmetic Operators
+ - * / %🔹 Assignment Operators
= += -=🔹 Comparison Operators
== === != !== > <Important rule
•
== checks value only •
=== checks value + typeAlways use
===🔀 Logical Operators
- AND →
&&- OR →
||- NOT →
!Example:
age > 18 && isLoggedIn⚠️ Common Beginner Mistakes
- Using
var- Mixing string and number
- Using
== instead of ===- Forgetting
const for fixed values🧪 Mini Practice Task
- Create variables for name, age, isStudent
- Create an array of skills
- Compare age with 18
- Print result using console.log
✅ Mini Practice Task – Solution 🧠
📌 1️⃣ Create variables for name, age, isStudent
const name = "Deepak";-
let age = 25;
let isStudent = true;
const used for fixed value-
let used where value may change📚 2️⃣ Create an array of skills
let skills = ["HTML", "CSS", "JavaScript"];- Arrays store multiple values
- Order matters
🔍 3️⃣ Compare age with 18
let isAdult = age >= 18;- Returns true or false
🖨️ 4️⃣ Print result using console.log
console.log("Name:", name);
console.log("Age:", age);
console.log("Is Student:", isStudent);
console.log("Skills:", skills);
console.log("Is Adult:", isAdult);
➡️ Double Tap ♥️ For More