DEV Community

Sandip Das
Sandip Das

Posted on

Modern JavaScript Features You Should Know (2024–2025)

JavaScript keeps evolving β€” here are some recent and upcoming features that caught my attention:

πŸ”Ή Array.prototype.toSorted() – Immutable sort
πŸ”Ή Object.hasOwn() – Safer hasOwnProperty
πŸ”Ή findLast() / findLastIndex() – Search from the end
πŸ”Ή Top-level await – No more wrapping in async
πŸ”Ή Promise.withResolvers() – Cleaner promise control
πŸ”Ή Record & Tuple (proposal) – Immutable data structures

**1. Array.prototype.toSorted()
**Non-mutating alternative to sort().

const numbers = [3, 1, 2];
const sorted = numbers.toSorted(); // [1, 2, 3]
console.log(numbers); // [3, 1, 2] – original array unchanged
Great for immutability and functional programming

**2. Object.hasOwn()
**Safer and clearer alternative to hasOwnProperty.

const user = { name: "Alex" };
Object.hasOwn(user, "name"); // true
Avoids prototype chain issues.

**3. Top-level await
**You can now use await outside of async functions in ES modules.

const data = await fetch("/api/data").then(res => res.json());
console.log(data);
Works only in modules (type="module" in HTML or .mjs files).

**4. Promise.withResolvers() (ES2024 Proposal)
**Cleaner way to create and control external promise resolution.

const { promise, resolve, reject } = Promise.withResolvers();
Very useful in custom async workflows.

**5. Array.prototype.findLast() and findLastIndex()
**Find from the end of an array.

[1, 2, 3, 4].findLast(x => x % 2 === 0); // 4
Efficient backward searching

Have you started using any of these? I'd love to hear your thoughts!

Top comments (0)