check last string in array javascript code example
Example 1: js array last element get
.slice(-1)[0]
Example 2: javascript array last element
var lastEle = arr.slice(-1)[0];
// or
var lastEle = arr.slice(-1).pop();
.slice(-1)[0]
var lastEle = arr.slice(-1)[0];
// or
var lastEle = arr.slice(-1).pop();