Programming
Modern JavaScript ES6+ Features
12 ديسمبر 202510 min read
Discover essential modern JavaScript features from ES6 and beyond.
const and let
Use const for constants and let for variables. Avoid var entirely in modern code.
const PI = 3.14159; // Constant
let count = 0; // Variable
count = 1; // ✓ Allowed
PI = 3; // ✗ Error
Arrow Functions
// Traditional
const add = function(a, b) { return a + b; };
// ES6 Arrow
const add = (a, b) => a + b;
const greet = name => `Hello, ${name}`;
Destructuring
// Objects
const { name, age } = user;
// Arrays
const [first, second, ...rest] = numbers;
// Parameters
function greet({ name, greeting = "Hello" }) {
return `${greeting}, ${name}`;
}
Spread and Rest
// Spread
const merged = [...arr1, ...arr2];
const copy = { ...obj, newProp: value };
// Rest
function sum(...numbers) {
return numbers.reduce((a, b) => a + b, 0);
}
Conclusion
ES6+ features make JavaScript cleaner and more powerful. Master these fundamentals for modern development.
Tags
#JavaScript#ES6#Modern JS#Frontend#Basics