How to Get Last Element of Array in Javascript?

By Hardik Savani November 5, 2023 Category : Javascript jQuery

Hello Folks,

Are you looking for an example of javascript get last element of array. I explained simply about javascript get last element of array. you can see get last index value of array in javascript. I explained simply step by step get last index of array in javascript. Alright, let’s dive into the steps.

Whenever you require to get last element value then you can use bellow example. I give you three way to get last element value in jquery. So let's see following example:


<script type="text/javascript">

var languages = ["PHP", ".Net", "Java", "Javascript"];

var last_element = languages[languages.length-1];


var last_element2 = languages.pop();


var last_element3 = languages.slice(-1)[0];



Tags :