array js target last value code example
Example 1: javascript get last element in an array
var last = arr.slice(-1)[0]
Example 2: get last item in array javascript
var colors = ["black", "white", "red", "yellow"];
var yellow = colors[colors.length - 1];