last element of array of objects javascript code example Example: last element of an array javascript var myArray = [1, 2, 3, 4]; myArray[myArray.length - 1];