Thursday, November 28, 2024
This year's juiciest JavaScript features
November 28, 2024 | | | New coding puzzle to train your brain✨ | | | Featured content | | 2024 was an incredible year of brand new JS feature upgrades with ES15. | We had promising upcoming features like the safe assignment operator ?= | // ❌ Before: // ❌ Deep nesting of try-catch for different errors async function fetchData() { try { const response = await fetch('https://api.codingbeautydev.com/docs'); try { const data = await response.json(); return data; } catch (parseError) { console.error(parseError); } } catch (networkError) { console.error(networkError); } } // ✅ After: async function fetchData() { const [networkError, response] ?= await fetch('https://codingbeautydev.com'); if (networkError) return console.error(networkError); const [parseError, data] ?= await response.json(); if (parseError) return console.error(parseError); return data; }
| From sophisticated async features to syntactic array sugar and modern regex, JavaScript coding became easier and faster than ever. | 1. Native array group-by is here | const fruits = [ { name: 'pineapple🍍', color: '🟡' }, { name: 'apple🍎', color: '🔴' }, { name: 'banana🍌', color: '🟡' }, { name: 'strawberry🍓', color: '🔴' }, ]; const groupedByColor = Object.groupBy( fruits, (fruit, index) => fruit.color ); console.log(groupedByColor);
| Literally the only thing keeping dinosaur Lodash alive — no more! | | I was expecting a new instance method like Array.prototype.groupBy but they made it static for whatever reason. | | Then we have Map.groupBy to group with object keys: | const array = [1, 2, 3, 4, 5]; const odd = { odd: true }; const even = { even: true }; Map.groupBy(array, (num, index) => { return num % 2 === 0 ? even: odd; }); // => Map { {odd: true}: [1, 3, 5], {even: true}: [2, 4] }
| Almost no one ever groups arrays this way though, so will probably be far less popular. | | Instantly add file uploads to your app with Pinata's API | Pinata's File API lets developers integrate file uploads and retrieval in just minutes. No complex setup, no configuration headaches—just fast and scalable file management. | Start building! | Thanks for taking the time to read today's issue. | Best, The Coding Beauty team |
| | Update your email preferences or unsubscribe here © 2024 Beneebo LLC 1603 Capitol Avenue, Suite 413A, #3255 Cheyenne, Wyoming 82001, United States of America | | Terms of Service |
|
|
|
|
|
0 Komentar untuk "The 5 most amazing JS features from 2024"