bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/Node.js/JS & TS Features
Node.js•JS & TS Features

Node.js ES6+ Features

Concept visual

Node.js ES6+ Features

push / pop from the top({[← top

What is ES6+?

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

Avoid common JavaScript pitfalls

Create more maintainable applications

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 - scoped

Example:

let 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

Arrow functions provide a concise syntax for writing functions and automatically bind this to the surrounding context.

Key benefits of arrow functions:

Shorter syntax for simple functions

Implicit return for one-line expressions

Lexical this binding (arrow functions don't create their own this context)

Example: Arrow Functions

// 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 literals (template strings) provide an elegant way to create strings with embedded expressions using backticks ( ` ).

Key features of template literals:

String interpolation with

${expression}

syntax

Multi-line strings without escape characters

Tagged templates for advanced string processing

Example: Template Literals

// 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

Destructuring allows you to extract values from arrays or properties from objects into distinct variables with a concise syntax.

Key features of destructuring:

Extract multiple values in a single statement

Assign default values to extracted properties

Rename properties during extraction

Skip elements in arrays

Extract deeply nested properties

Example: Object Destructuring

// Basic object destructuring const user = { name: 'Alice', age: 30, location: 'New York' };

const { name, age } = user;
console.log(name, age);

Next

Node.js Process Management