JavaScript se rapidně vyvíjí. ES2024 přináší Array grouping, well-formed Unicode strings a další užitečné features.
Klíčové features¶
// Array grouping (ES2024) const people = [ { name: ‘Jan’, age: 30 }, { name: ‘Eva’, age: 25 }, { name: ‘Tom’, age: 30 }, ]; const byAge = Object.groupBy(people, p => p.age); // { 25: [{name:’Eva’,…}], 30: [{name:’Jan’,…},{name:’Tom’,…}] } // Promise.withResolvers const { promise, resolve, reject } = Promise.withResolvers(); // Temporal API (Stage 3) const now = Temporal.Now.plainDateTimeISO(); const date = Temporal.PlainDate.from(‘2025-03-15’);
Moderní syntax¶
// Optional chaining + nullish coalescing const city = user?.address?.city ?? ‘Unknown’; // Top-level await const data = await fetch(‘/api’).then(r => r.json()); // Structuring clone const deep = structuredClone(original); // at() — negative indexing const last = arr.at(-1);
Klíčový takeaway¶
Používejte moderní syntax — groupBy, at(), structuredClone. Temporal nahradí Date objekt.