Access JavaScript Array Elements from the End with .at() Method

Access array elements from the end in JavaScript (Clean Way) 🔥 - 𝐎𝐥𝐝 𝐰𝐚𝐲 👇 arr[arr.length - 1] - 𝐌𝐨𝐝𝐞𝐫𝐧 & 𝐫𝐞𝐚𝐝𝐚𝐛𝐥𝐞 𝐰𝐚𝐲 👇 arr.at(-1) - Cleaner syntax - Better readability - Works for strings too - Perfect for last / second-last elements If you’re writing modern JavaScript, .at() is a small change that makes your code look professional 💡 Follow Tapas Sahoo for more related content 🙏 Which one do you usually use? 👇 Comment below ⬇️ #JavaScript #ES2022 #WebDevelopment #FrontendDeveloper #CodingTips #CleanCode #Programming #JS #Developers #LearnJavaScript

  • graphical user interface

This is such a nice example of how JavaScript keeps getting more developer-friendly. The `.at()` method really shows how thoughtful API design can make our code both cleaner and easier to understand.

To view or add a comment, sign in

Explore content categories