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