Here is my JavaScript code so far:
var linkElement = document.getElementById(\"BackButton\"); var loc_array = document.location.href.split(\'/\'); var newT =
Use Array.pop:
var lastItem = anArray.pop();
Important : This returns the last element and removes it from the array