Hey Web Codders! 👋
This is Vikas Sankhla, your tech buddy and founder of the Web Codder YouTube channel.
Today, we’ll learn how to make JavaScript code shorter, cleaner, and smarter using ES6+ features. 💡
Let’s go step by step and make it crazy simple. 😎
🎁 1. Destructuring Assignment – Unpacking Like a Pro
Destructuring lets you pull out values from arrays or objects quickly.
📦 Example with Arrays:
jsCopyEditlet fruits = ["🍎", "🍌", "🍇"];
let [apple, banana, grape] = fruits;
console.log(apple); // 🍎
No more fruits[0]
, fruits[1]
—you just grab them all in one line!
📦 Example with Objects:
jsCopyEditlet user = { name: "Vikas", age: 30 };
let { name, age } = user;
console.log(name); // Vikas
👉 Works great in functions too!
jsCopyEditfunction greet({ name }) {
console.log(`Hello, ${name}! 👋`);
}
greet(user); // Hello, Vikas! 👋

✨ 2. Template Literals – String Magic 🎩
Tired of +
everywhere in strings?
Use template literals with backticks (`
) and ${}
to insert variables easily.
Old way:
jsCopyEditlet name = "Web Codder";
console.log("Hello, " + name + "!");
New way with Template Literals:
jsCopyEditconsole.log(`Hello, ${name}! 👋`);
✅ Cleaner
✅ Easy to read
✅ Multi-line support!
jsCopyEditconsole.log(`
Welcome, ${name}!
You're awesome. 😎
`);
⚙️ 3. Default, Rest & Spread – The Trio of Power 💪
🔹 Default Parameters – Set values if nothing is passed
jsCopyEditfunction greet(name = "Guest") {
console.log(`Hello, ${name}!`);
}
greet(); // Hello, Guest!
🔹 Rest Parameters – Catch all extras into an array
jsCopyEditfunction addAll(...nums) {
return nums.reduce((a, b) => a + b);
}
console.log(addAll(1, 2, 3, 4)); // 10
🔹 Spread Operator – Spread things out
Copy or merge arrays/objects easily.
jsCopyEditlet nums1 = [1, 2];
let nums2 = [...nums1, 3, 4];
console.log(nums2); // [1, 2, 3, 4]
![2.9 Javascript Es6+ Features – Modern Javascript Syntax Made Easy 2 Rest Vs Spread Visual – “... In” Vs “... Out”]](https://webcodder.dev/wp-content/uploads/2025/05/1_mol0dUrn4wr_D11VyPJSpg-1024x576.jpg)
🗺️ 4. Map, Set, WeakMap, WeakSet – New Data Structures
🔹 Map
– Key-value pairs (better than plain objects!)
jsCopyEditlet myMap = new Map();
myMap.set("name", "Vikas");
myMap.set("channel", "Web Codder");
console.log(myMap.get("name")); // Vikas
✅ Can use any type as key
✅ Keeps order
✅ Easy to iterate
🔹 Set
– Unique values only
jsCopyEditlet mySet = new Set();
mySet.add("apple");
mySet.add("banana");
mySet.add("apple"); // Duplicate ignored!
console.log(mySet.size); // 2
✅ No duplicates
✅ Great for filtering
🔹 WeakMap
and WeakSet
– Like Map/Set, but:
- Keys must be objects
- Don’t prevent garbage collection
- Used in advanced memory-sensitive use cases
You won’t need them much as a beginner, but it’s good to know they exist! 💡

📋 Summary Table
Feature | What It Does | Example |
---|---|---|
Destructuring | Unpack values from objects/arrays | let { name } = user; |
Template Literals | Write strings with variables | `Hi ${name}` |
Default Parameters | Set default values in functions | function greet(name = "Guest") |
Rest Parameters | Collect all remaining values in array | (...args) |
Spread Operator | Spread out array/object elements | [...arr] , {...obj} |
Map | Key-value pair with any key type | new Map() |
Set | Stores unique values | new Set() |
WeakMap / WeakSet | Memory-friendly object-key collections | new WeakMap() |
🧠 Final Thoughts
These modern features make JavaScript faster to write, easier to read, and more powerful. 💪
Start using these in your projects today and see the magic happen! ✨
📢 Learn More with Web Codder!
If you found this helpful, imagine what you’ll learn in our videos and posts! 🤩
👉 Subscribe now on YouTube
🔗 YouTube – Web Codder
📸 Follow us on Instagram
🔗 Instagram – @web_codder_official
💬 Join our WhatsApp tech group
🔗 Join here
Let’s build the future of the web, one line of code at a time. 💻❤️