1let arr = [1,2,3]
2arr[arr.length - 1] //returns last element in an array
1var my_array = /* some array here */;
2var last_element = my_array[my_array.length - 1];
1var colors = ["red","blue","green"];
2var green = colors[colors.length - 1]; //get last item in the array
3
1const str = "Users/Edit/12345";
2let idx = str.lastIndexOf("/"); // returns 10
3idx = str.lastIndexOf("x"); // returns -1
4
5idx = str.lastIndexOf("Edit") // returns 6
6idx = str.lastIndexOf("edit") // returns -1 -- case sensitive
7
8// add "from" parameter
9// the search happens backwards, starting at the provided from parameter
10idx = str.lastIndexOf("s"); // returns 4
11idx = str.lastIndexOf("s", 3); // returns 1
12