how to get the last element in a list javascript code example Example: javascript last element of array var last = arr.slice(-1)[0]