js array last elemnt code example Example 1: javascript last element of array arr.slice(-1)[0] Example 2: javascript last element of array var last = arr.slice(-1)[0]