Modern JavaScript (ES6+)
JavaScript has evolved rapidly since ES6 (2015). Each year brings new features that make the language more expressive and developer-friendly. This chapter covers the essential modern features you should know.1. Destructuring
Extract values from arrays and objects into distinct variables.Array Destructuring
Object Destructuring
Function Parameters
2. Spread Operator
Expand iterables (arrays, strings) or objects.Arrays
Objects (ES2018)
3. Template Literals
Enhanced string formatting with backticks.4. Modules (ES6)
Organize code into reusable files.Named Exports
Default Exports
Dynamic Imports
Load modules on demand (code splitting).5. Classes (ES6+)
Syntactic sugar over prototypes with additional features.6. New Data Structures
Map (Key-Value, Any Type Keys)
Set (Unique Values)
WeakMap & WeakSet
Keys are weakly held (garbage collected if no other references).7. New Array & Object Methods
Array Methods (ES2019+)
Object Methods (ES2017+)
8. Other Modern Features
Optional Chaining & Nullish Coalescing
Logical Assignment (ES2021)
Numeric Separators (ES2021)
String Methods (ES2017+)
Summary
Modern JavaScript is expressive, concise, and powerful:- Destructuring: Extract values from objects/arrays elegantly.
- Spread/Rest: Combine, copy, and collect elements.
- Modules: Organize code with
import/export. - Classes: Clean OOP syntax with private fields.
- Map/Set: Powerful data structures beyond objects/arrays.
- Optional Chaining: Safe property access with
?..