last elements of array javascript code example
Example 1: javascript last element of array
arr.slice(-1)[0]
Example 2: javascript array last element
var lastEle = arr.slice(-1)[0];
// or
var lastEle = arr.slice(-1).pop();
arr.slice(-1)[0]
var lastEle = arr.slice(-1)[0];
// or
var lastEle = arr.slice(-1).pop();