2.9 JavaScript ES6+ Features – Modern JavaScript Syntax Made Easy

Table of Contents

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! 👋

Low Code Development Vs Traditional Development Key Differences
2.9 Javascript Es6+ Features – Modern Javascript Syntax Made Easy 4


✨ 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]

Rest Vs Spread Visual – “... In” Vs “... Out”]
2.9 Javascript Es6+ Features – Modern Javascript Syntax Made Easy 5


🗺️ 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! 💡


Table Comparing Object Vs Map, Array Vs Set
2.9 Javascript Es6+ Features – Modern Javascript Syntax Made Easy 6


📋 Summary Table

FeatureWhat It DoesExample
DestructuringUnpack values from objects/arrayslet { name } = user;
Template LiteralsWrite strings with variables`Hi ${name}`
Default ParametersSet default values in functionsfunction greet(name = "Guest")
Rest ParametersCollect all remaining values in array(...args)
Spread OperatorSpread out array/object elements[...arr], {...obj}
MapKey-value pair with any key typenew Map()
SetStores unique valuesnew Set()
WeakMap / WeakSetMemory-friendly object-key collectionsnew 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. 💻❤️

Share the Post:
Picture of Web Codder

Web Codder

Vikas Sankhla is a seasoned Full Stack Developer with over 7 years of experience in web development. He is the founder of Web Codder, a platform dedicated to providing comprehensive web development tutorials and resources. Vikas specializes in the MERN stack (MongoDB, Express.js, React.js, Node.js) and has been instrumental in mentoring aspiring developers through his online courses and content. His commitment to simplifying complex web technologies has made him a respected figure in the developer community.

Related Posts