Loading lesson path
Concept visual
ES6 (ECMAScript 2015) and later versions add powerful new features to JavaScript that make your code more expressive, concise, and safer. Node.js has excellent support for modern JavaScript features. Node.js Compatibility:
Formula
All modern versions of Node.js (10 +) have excellent support for ES6 + features.Newer versions support even more recent JavaScript additions from ES2020 and beyond. These modern JavaScript features help you: Write cleaner, more readable code
Reduce the need for external libraries let and const The let and const keywords replaced var as the preferred way to declare variables:
let allows you to declare variables that can be reassigned const declares variables that cannot be reassigned (but object properties can still be modified)Formula
Both are block - scoped, unlike var which is function - scopedlet and const
// Using let (can be changed)
let score = 10;
score = 20;
// Using const (cannot be reassigned)
const MAX_USERS = 100;
// Block scope with let if (true) {
let message = 'Hello';
console.log(message); // Works here
}Arrow functions provide a concise syntax for writing functions and automatically bind this to the surrounding context.
Lexical this binding (arrow functions don't create their own this context)
// Traditional function function add(a, b) {
return a + b;
}
// Arrow function (same as above)
const addArrow = (a, b) => a + b;
// Single parameter (no parentheses needed)
const double = num => num * 2;
// No parameters (parentheses needed)
const sayHello = () => 'Hello!';
// Using with array methods const numbers = [1, 2, 3];
const doubled = numbers.map(num => num * 2);
console.log(doubled);When NOT to use arrow functions: Object methods (where you need this to reference the object) Constructor functions (arrow functions can't be used with new) Event handlers where this should refer to the element
Template literals (template strings) provide an elegant way to create strings with embedded expressions using backticks ( ` ).
${expression}// Basic string interpolation const name = 'Alice';
console.log(`Hello, ${name}!`);
// Multi-line string const message = `Formula
This is a multi - line string in JavaScript.`;
console.log(message);
// Simple expression const price = 10;
const tax = 0.2;
console.log(`Total: $${price * (1 + tax)}`);Destructuring allows you to extract values from arrays or properties from objects into distinct variables with a concise syntax.
// Basic object destructuring const user = { name: 'Alice', age: 30, location: 'New York' };
const { name, age } = user;
console.log(name, age);