Tutorial2025-01-15
Top ES6+ Features Every Developer Should Know
Explore the modern JavaScript features that will make your code cleaner and more efficient.
Arrow Functions
Shorter function syntax:
const add = (a, b) => a + b;
Template Literals
String interpolation:
const greeting = \Hello, ${name}!\;
Destructuring
Extract values easily:
const { name, age } = user;
const [first, second] = array;
Spread Operator
Expand elements:
const newArr = [...arr1, ...arr2];
const newObj = { ...obj1, ...obj2 };
Default Parameters
function greet(name = 'World') {
return \Hello, ${name}!\;
}
Rest Parameters
Collect remaining arguments:
function sum(...numbers) {
return numbers.reduce((a, b) => a + b, 0);
}
Optional Chaining
Safe property access:
const city = user?.address?.city;
Nullish Coalescing
Default for null/undefined only:
const value = input ?? 'default';