Concept Explanation
Before 2015, JavaScript barely changed for years. Then ES6 (ECMAScript 2015) landed — the biggest update in the language's history — bringing let/const, arrow functions, classes, template literals, destructuring, and promises all at once.
Since then, JavaScript ships a new version every year. This ever-growing modern version is often called ESNext. Learning "modern JS" really means learning the handful of ES6+ features that now appear in essentially every codebase.
Syntax or Core Structure
Old Way vs. Modern Way
// Before ES6
var name = "Sam";
var greeting = "Hello " + name + "!";
var double = function (n) { return n * 2; };
// ES6+
const name = "Sam";
const greeting = `Hello ${name}!`; // template literal
const double = n => n * 2; // arrow function
The Highlights by Year
- ES6 (2015):
let/const, arrow functions, template literals, classes, destructuring, modules. - ES2017:
async/await,Object.entries/values. - ES2020+: nullish coalescing (
??), optional chaining (?.),Promise.allSettled.
Real World Example
Open almost any React, Vue, or Node project today and the first lines are ES6: import statements, const declarations, and arrow functions. These aren't optional extras any more — they're the default dialect every JavaScript job expects you to read and write fluently.
Common Mistakes
- Still reaching for
var:varhas confusing scoping rules. In modern code, useconstby default andletonly when you must reassign. - Trying to memorize all of it: You don't need to. Master five features —
const/let, arrows, template literals, destructuring, and modules — and the rest follow naturally. - Ignoring browser support: Very old browsers don't speak ES6. A tool called Babel "translates" modern JS back down for them (covered in the Tooling module).
Best Practices
constfirst: default toconst; downgrade toletonly when a value truly changes.- Prefer template literals:
${}beats string concatenation for anything with a variable in it. - Adopt gradually: you can mix modern features into old code one line at a time — no full rewrite required.
Practice Exercises
- The Translator: Take three
var+ string-concatenation lines and rewrite them usingconstand template literals. - The Feature Hunt: Research and list five features added in the last two years (ES2022 or ES2023).
- The Strict Check: Add
"use strict";to the top of a script and find one bug it now catches that it silently ignored before.