how to take last element from the list in javascript code example Example: js array last element get .slice(-1)[0]