how to getelement at last of array in javascript code example Example: javascript last element of array arr.slice(-1)[0]