๐—ง๐—ต๐—ฟ๐—ฒ๐—ฒ ๐— ๐—ผ๐—ฑ๐—ฒ๐—ฟ๐—ป ๐—๐—ฎ๐—๐—ฎ๐—ฆ๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜ ๐—™๐—ฒ๐—ฎ๐˜๐˜‚๐—ฟ๐—ฒ๐˜€ JavaScript has changed a lot in recent years. You can now use cleaner, more expressive alternatives to common coding patterns. Three useful additions are:

Creating a deep copy of an object used to be a challenge. You had to use hacks like: const copy = JSON.parse(JSON.stringify(obj)); This approach works for simple objects, but it breaks with complex data types. A better way to make a deep copy is: const copy = structuredClone(obj); This function preserves many built-in JavaScript types, including Dates, Maps, and Sets.

Accessing the last element of an array used to look like this: const lastItem = arr[arr.length - 1]; The newer at() method provides a cleaner alternative: const lastItem = arr.at(-1); Negative indexes count from the end of the array.

You can also use findLast() to get the last active user in an array: const user = users.findLast(u => u.active); This method searches from the end of the array and returns the first matching element.

Source: https://dev.to/zamfir80/three-modern-javascript-features-that-replace-older-patterns-1ogm