DEV Community

Cover image for 10 Modern JavaScript (ES6+) Features Every Developer Should Know ⚡
Flud
Flud

Posted on

10 Modern JavaScript (ES6+) Features Every Developer Should Know ⚡

JavaScript has come a long way since its early days. With ES6 and beyond, the language introduced powerful new features that make code cleaner, shorter, and more maintainable.

If you’re still writing JavaScript the old way, here are 10 modern features you should start using today:


1. let and const 🛡️

Block-scoped variables replace var.

let count = 1;     // can be reassigned
const PI = 3.1416; // cannot be reassigned
Enter fullscreen mode Exit fullscreen mode

2. Template Literals 📜

No more messy string concatenation:

const name = "Alice";
console.log(`Hello, ${name}!`);
Enter fullscreen mode Exit fullscreen mode

3. Arrow Functions ➡️

Shorter syntax and lexical this binding:

const add = (a, b) => a + b;
Enter fullscreen mode Exit fullscreen mode

4. Default Parameters 🧩

Give function parameters default values:

function greet(name = "stranger") {
  return `Hello, ${name}`;
}
Enter fullscreen mode Exit fullscreen mode

5. Destructuring 🔓

Extract values from arrays/objects easily:

const [x, y] = [10, 20];
const {name, age} = {name: "Bob", age: 25};
Enter fullscreen mode Exit fullscreen mode

6. Spread & Rest Operators ...

// Spread
const arr1 = [1, 2];
const arr2 = [...arr1, 3, 4]; // [1,2,3,4]

// Rest
function sum(...nums) {
  return nums.reduce((a, b) => a + b, 0);
}
Enter fullscreen mode Exit fullscreen mode

7. Classes 👩‍🏫

Cleaner syntax for prototypes:

class Person {
  constructor(name) {
    this.name = name;
  }
  greet() {
    console.log(`Hi, I’m ${this.name}`);
  }
}
Enter fullscreen mode Exit fullscreen mode

8. Promises & Async/Await ⏳

Handle async code without callback hell:

async function fetchData() {
  const res = await fetch("https://api.example.com");
  const data = await res.json();
  console.log(data);
}
Enter fullscreen mode Exit fullscreen mode

9. Modules 📦

Use import and export to split code into files:

// utils.js
export const add = (a, b) => a + b;

// main.js
import { add } from "./utils.js";
Enter fullscreen mode Exit fullscreen mode

10. Optional Chaining & Nullish Coalescing 🔗

Avoid crashes from undefined values:

const user = {};
console.log(user?.profile?.name ?? "Guest"); 
Enter fullscreen mode Exit fullscreen mode

🏆 Wrapping Up

These ES6+ features make JavaScript cleaner, easier, and more powerful. If you haven’t adopted them yet, start using them in your projects — your code (and your teammates) will thank you.


💬 Which modern JS feature do you use the most? Any personal favorite that saves you tons of time? Share in the comments 👇


Top comments (0)