Advertisement · 728 × 90
#
Hashtag
#ES2023
Advertisement · 728 × 90
toSorted(), toReversed(), toSpliced()… enfin des méthodes sûres en JS ! 🤯 #webdev #javascript #code
toSorted(), toReversed(), toSpliced()… enfin des méthodes sûres en JS ! 🤯 #webdev #javascript #code La plupart des développeurs JavaScript utilisent sort(), reverse() ou splice() sans s’en rendre compte… Et pourtant, ces méthodes modifient directement vos tableaux d’origine ⚠️ ➤ Besoin de trier…

JavaScript ajoute enfin des méthodes immuables pour manipuler les tableaux sans les muter :

toSorted()
toReversed()
toSpliced()

➕ Finies les mutations imprévues
➕ Idéal pour un style fonctionnel

🎥 Démo courte → youtube.com/shorts/tiv8f...

#JavaScript #WebDev #CleanCode #ES2023

2 0 0 0
Preview
Stop using .reverse().find(): meet findLast() - Matt Smith Learn how Array.prototype.findLast() and findLastIndex() let you search JavaScript arrays from the end—no .reverse() required. Cleaner, safer, and perfect for UI logic.

#Development #Techniques
Stop using ‘.reverse().find()’ in JavaScript · ‘findLast()’ and ‘findLastIndex()’ are cleaner and safer ilo.im/1672pg by Matt Smith

_____
#Arrays #ES2023 #JavaScript #React #Browser #WebDev #Frontend #Backend

1 0 0 0
Preview
Finally, safe array methods in JavaScript - Matt Smith Learn how to safely sort, reverse, and splice arrays in JavaScript using ES2023 methods toSorted(), toReversed(), and toSpliced(). Perfect for React and modern JS development.

#Development #Introductions
Safe array methods in JavaScript · A tiny syntax change makes a big difference ilo.im/166pp4 by Matt Smith

_____
#Arrays #JavaScript #ES2023 #React #NodeJS #Browser #WebDev #Frontend #Backend

1 0 0 0
Preview
Mastering JavaScript’s toSorted(): Immutable Sorting Made Easy | TechWithTwin Array.prototype.toSorted() function was introduced in ECMAScript 2013, which provided an immutable approach to sorting arrays, addressing…

🆕 JavaScript just got cleaner with toSorted()!

No more mutating arrays—sort immutably and write safer code. 💡

📖 Dive into how Array.prototype.toSorted() works and why you should use it:

medium.com/@techwithtwi...

#JavaScript #ES2023 #TechWithTwin

0 0 0 0
JavaScript example:
const arr = [1, 2, 3];

// New in ES2023
const newArr = arr.with(1, 42);
console.log(newArr); // [1, 42, 3]

// Old way (spread with slice)
const oldArr = [...arr.slice(0, 1), 42, ...arr.slice(2)];
console.log(oldArr); // [1, 42, 3]

JavaScript example: const arr = [1, 2, 3]; // New in ES2023 const newArr = arr.with(1, 42); console.log(newArr); // [1, 42, 3] // Old way (spread with slice) const oldArr = [...arr.slice(0, 1), 42, ...arr.slice(2)]; console.log(oldArr); // [1, 42, 3]

📢 #JavaScript devs, meet array.with() from #ES2023! 🚀
Replace an array element without mutation.

✅ with() is cleaner and shorter!

Check example 👇

1 0 0 0
JavaScript example:

const users = [
  { name: "Simon", age: 25 },
  { name: "John", age: 30 },
  { name: "Mia", age: 25 }
];

const grouped = Object.groupBy(users, user => user.age);
console.log(grouped);
/*
{
  25: [{ name: "Simon", age: 25 }, { name: "Mia", age: 25 }],
  30: [{ name: "John", age: 30 }]
}
*/

JavaScript example: const users = [ { name: "Simon", age: 25 }, { name: "John", age: 30 }, { name: "Mia", age: 25 } ]; const grouped = Object.groupBy(users, user => user.age); console.log(grouped); /* { 25: [{ name: "Simon", age: 25 }, { name: "Mia", age: 25 }], 30: [{ name: "John", age: 30 }] } */

📌 Object.groupBy()

Since #ES2023 you can use Object.groupBy() to group array elements based on key!

Check example 👇

Very useful! 🚀 #JavaScript

4 0 0 0
Screenshot of the following snippet:
```ts
return rows.rows.map((d) => {
	d.creators.toSorted((a, b) => {
		return a.sort_order_in_content -b.sort_order_in_content;
	})
	return d;
});
```

Screenshot of the following snippet: ```ts return rows.rows.map((d) => { d.creators.toSorted((a, b) => { return a.sort_order_in_content -b.sort_order_in_content; }) return d; }); ```

Can you spot the error?

#Javascript #Typescript #ES2023 #ECMAScript

3 0 0 1
JavaScript Array with() Method (new in ES 2023)
JavaScript Array with() Method (new in ES 2023) What's with the new with() method on JavaScript arrays?with() is new in ECMAScript 2023, also known as ES 14, which is the standard for JavaScript.In this vi...

What's with the new with() method on JavaScript arrays?

Use the with() method instead of bracket syntax to modify array elements in an immutable way.

Check out my latest YT video here: youtu.be/Nxe88SVnEOU

#javascript #es2023 #angular

2 0 0 0