← All blog posts
⚡
javascript

JavaScript ES2025: New Features You Can Start Using Today

ES2025 brings exciting features like Pipe operator, Records & Tuples, Pattern Matching, and more. Learn what is shipping and what is still in proposal stage.

JavaScript ES2025: New Features

JavaScript continues to evolve. ES2025 (officially ES16) brings several exciting features that make code cleaner and more expressive.

1. Pipe Operator (|>)

The pipe operator lets you chain function calls in a readable left-to-right flow. No more nested parentheses!

javascript
// Without pipe
const result = capitalize(reverse(trim(input)));

// With pipe
const result = input
  |> trim
  |> reverse
  |> capitalize;

2. Records and Tuples

Immutable versions of objects and arrays. They use # prefix and are deeply frozen by default.

javascript
const record = #{ name: "w3primecode", lang: "hi" };
const tuple = #[1, 2, 3, 4];

// Deep equality works!
#{ a: 1, b: 2 } === #{ a: 1, b: 2 }; // true
#[1, 2, 3] === #[1, 2, 3]; // true

3. Pattern Matching

Switch on steroids. Match object shapes, arrays, and patterns.

javascript
match (response) {
  { status: 200, data } => renderData(data),
  { status: 404 } => showNotFound(),
  { status: >= 500 } => showServerError(),
  _ => showUnknownError()
}

4. Array.prototype.group()

Group array items by a key. Cleaner than writing reduce.

javascript
const posts = [
  { title: "CSS Tips", category: "css" },
  { title: "HTML Guide", category: "html" },
  { title: "More CSS", category: "css" },
];

const grouped = posts.group(p => p.category);
// { css: [...], html: [...] }

5. Array.prototype.findLast() and findLastIndex()

Find the last matching element without reversing the array.

javascript
const lastEven = [1, 2, 3, 4, 5].findLast(n => n % 2 === 0); // 4

6. Object.hasOwn()

Safer than Object.prototype.hasOwnProperty.call().

javascript
const obj = Object.create(null);
obj.key = "value";

Object.hasOwn(obj, "key"); // true
// obj.hasOwnProperty("key") would throw!

7. Error Cause

Chain errors with context. Great for debugging.

javascript
try {
  await fetchData();
} catch (err) {
  throw new Error("Failed to load user", { cause: err });
}

8. structuredClone()

Deep clone objects (including Dates, Maps, Sets) without hacks.

javascript
const original = { date: new Date(), nested: { a: 1 } };
const copy = structuredClone(original);

9. Top-level Await

Use await at the top level of ES modules. No IIFE wrapper needed.

javascript
// module.mjs
const data = await fetch('/api/data').then(r => r.json());
export default data;

10. Array.prototype.at()

Negative indexing like Python.

javascript
const arr = [10, 20, 30, 40];
arr.at(-1); // 40
arr.at(-2); // 30

Browser Support

FeatureChromeFirefoxSafari
Array.group✅✅✅
findLast✅✅✅
Object.hasOwn✅✅✅
Error cause✅✅✅
structuredClone✅✅✅
Top-level await✅✅✅
Array.at✅✅✅
Pipe operator⚠️⚠️⚠️
Records & Tuples⚠️⚠️⚠️
Pattern matching⚠️⚠️⚠️

⚠️ = still in proposal stage, may need transpilation

Conclusion

Most of these features are already in modern browsers. For cutting-edge proposals like Pipe and Pattern Matching, use Babel or TypeScript to transpile. Start using group(), findLast(), and structuredClone() today — your code will thank you.