📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
✅ Some premium posts are free to read — no account needed. Follow me on Medium to stay updated and support my writing.
🎓 Top 10 Udemy Courses (Huge Discount): Explore My Udemy Courses — Learn through real-time, project-based development.
▶️ Subscribe to My YouTube Channel (172K+ subscribers): Java Guides on YouTube
- Using array.length property
- Using slice() method
1. Using array.length property
let elements = [1,2,3,4,5,6,7,8,9];
const lastElement = elements[elements.length-1];
console.log(lastElement);
9
2. Using slice() method
let elements = [1,2,3,4,5,6,7,8,9];
const lastElement = elements.slice(-1);
console.log(lastElement);
[9]
Comments
Post a Comment
Leave Comment