๐Ÿš€ Modern JavaScript Features Since ES6 (2015โ€“2024)

JavaScript has evolved dramatically since ES6 (2015). Hereโ€™s a quick reference of all the major additions to the language, broken down by year and usefulness.


๐Ÿ“ฆ ES6 (2015) โ€” The Big Upgrade

โœ… Syntax & Variables

let x = 10;
const y = 20;
const sum = (a = 1, b = 2) => a + b;

โœ… Strings & Templates

const name = 'World';
console.log(`Hello, ${name}!`);

โœ… Destructuring

const { name, age } = user;
const [first, second] = arr;

โœ… Spread & Rest

const copy = { ...original };
const sum = (...nums) => nums.reduce((a, b) => a + b);

โœ… Objects

const key = 'dynamic';
const obj = {
  name,
  [key]: 42,
};

โœ… Classes

class Animal {
  constructor(name) {
    this.name = name;
  }
  speak() {
    console.log(`${this.name} speaks.`);
  }
}

โœ… Promises

fetch('/api')
  .then(res => res.json())
  .catch(console.error);

โœ… Modules

// utils.js
export function greet(name) {
  return `Hello, ${name}`;
}

// main.js
import { greet } from './utils.js';

โœจ Post-ES6 Enhancements - Incremental Goodness

๐Ÿ”น ES7 (2016)

  • Array.prototype.includes()
  • ** exponentiation: 2 ** 3

๐Ÿ”น ES8 (2017)

  • async/await
  • Object.entries(), Object.values()
  • String.padStart(), padEnd()

๐Ÿ”น ES9 (2018)

  • Spread in objects: { ...obj }
  • Rest in objects: const { a, ...rest } = obj
  • Promise.prototype.finally()

๐Ÿ”น ES10 (2019)

  • Array.prototype.flat(), flatMap()
  • Object.fromEntries()
  • Optional catch binding: catch {}

๐Ÿ”น ES11 (2020)

  • Optional chaining: user?.profile?.email
  • Nullish coalescing: value ?? 'default'
  • Promise.allSettled()
  • globalThis

๐Ÿ”น ES12 (2021)

  • Logical assignment: a ||= 1, b &&= 2, c ??= 3
  • Numeric separators: 1_000_000
  • String.prototype.replaceAll()

๐Ÿ”น ES13 (2022)

  • .at() method: array.at(-1)
  • Top-level await in modules

๐Ÿ”น ES14+ (2023โ€“2024)

  • Array.prototype.toSorted(), toReversed(), with()
  • Decorators (in TC39 Stage 3)
  • Record & Tuple (proposals)
  • Pattern matching (proposal)

๐Ÿง  Must-Know Modern JS Features

Feature Why Itโ€™s Useful
async/await Simplifies async code
Optional chaining (?.) Safe access to deep properties
Nullish coalescing (??) Smart default values
Object & Array destructuring Cleaner variable extraction
Spread/rest (...) Concise data manipulation
Modules (import/export) Better code organization
Promises & Promise.all() Parallel async operations

๐Ÿ”ง Bonus: Decorators (Experimental)

function Log(target, key, descriptor) {
  const original = descriptor.value;
  descriptor.value = function (...args) {
    console.log(`Calling ${key} with`, args);
    return original.apply(this, args);
  };
}

class MyClass {
  @Log
  doThing(a, b) {
    return a + b;
  }
}

Decorators allow you to annotate and modify classes, methods, properties, and parameters. Theyโ€™re widely used in frameworks like NestJS, but also powerful for things like logging, access control, and validation.

โš ๏ธ As of 2024, decorators are in Stage 3 of TC39 and available in TypeScript.