end of array js code example

Example 1: last element of array javascript

var my_array = /* some array here */;
var last_element = my_array[my_array.length - 1];

Example 2: how to get the end of an array javascript

let arr = [1, 2, 3, 4, 5, 6, 7, 8];
let last = arr.pop();

console.log(last);
//8


console.log("https://discord.gg/5yjWgMS")

Example 3: js last array element

var linkElement = document.getElementById("BackButton");
var loc_array = document.location.href.split('/');
var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-2]))); 
linkElement.appendChild(newT);