Here is my JavaScript code so far:
var linkElement = document.getElementById(\"BackButton\"); var loc_array = document.location.href.split(\'/\'); var newT =
const lastElement = myArray[myArray.length - 1];
This is the best options from performance point of view (~1000 times faster than arr.slice(-1)).
arr.slice(-1)