get last index array javascript code example Example 1: get last element of array javascript arr.slice(-1)[0] Example 2: get last element in array in javascript arr.slice(-1)[0]