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