TGViewer
Web Development Web Development @web_dev_bds · 4.43K subscribers
Post #713 512
✅ JavaScript Basics You Should Know 🌐✨

JavaScript is a scripting language used to make websites interactive handling user actions, animations, and dynamic content.

1️⃣ Variables & Data Types 
Use let for reassignable variables, const for constants (avoid var due to scoping issues).
let name = "Alex";  
const age = 25;

Data Types: string, number, boolean, object, array, null, undefined.

2️⃣ Functions 
Reusable blocks of code.
function greet(user) {
  return `Hello, ${user}`;
}

Or use arrow functions for concise syntax:
const greet = (user) => `Hello, ${user}`;


3️⃣ Conditionals
if (age > 18) {
  console.log("Adult");
} else {
  console.log("Minor");
}


4️⃣ Loops
for (let i = 0; i < 5; i++) {
  console.log(i);
}


5️⃣ Arrays & Objects
let fruits = ["apple", "banana"];
let person = { name: "John", age: 30 };


6️⃣ DOM Manipulation
document.getElementById("demo").textContent = "Updated!";


7️⃣ Event Listeners
button.addEventListener("click", () => alert("Clicked!"));


8️⃣ Fetch API (Async)
fetch("https://api.example.com").then(res => res.json()).then(data => console.log(data));


9️⃣ ES6 Features
⦁ let, const
⦁ Arrow functions
⦁ Template literals: Hello ${name}
⦁ Destructuring: const { name } = person;
⦁ Spread/rest operators: ...fruits

💡 Tip: Practice JS in browser console or use online editors like JSFiddle / CodePen.

💬 Tap ❤️ for more!
  • ❤ 1
  • 🔥 1
More from @web_dev_bds
  1. Oct 16, 2026📕Random React Tip: If you want to quickly log things from JSX (we've all been there), you…
  2. Oct 15, 2026Websites to Learn Every Technology
  3. Oct 13, 2026Docker vs Kubernetes
  4. Oct 12, 2026Post #1054
  5. Oct 11, 2026CSS Tip Stop centring tooltips with 𝚝𝚛𝚊𝚗𝚜𝚕𝚊𝚝𝚎: -𝟻𝟶%. near the edge of the scree…
  6. Oct 9, 2026JavaScript CheatSheet
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →