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