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. ๐ปโค๏ธ