how to get last added element to array code example
Example 1: Javascript get last item in array
var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
Example 2: javascript array last 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);