last Summary Returns the last element of the array. Signatures Click on a signature to select it and view its documentation. public T+ last() public T[] last(int n) Usage public T+ last() public T[] last(int n) Returns The last element of the array or undefined if the array contains no elements. The last n elements of the array. Parameters n The number of elements to extract from the end of the array. Description Returns the last element of the array. If there are no elements in the array, undefined will be returned. This method does not mutate the array. Returns the last n elements of the array. If n is greater than the array length, a copy of the entire array will be returned. Examples Basic Usage 1234import System; int[] arr = [ 3, 4, 5 ];Console.log(arr.last()); // 5 Get the last two elements of an array 1234import System; int[] arr = [ 3, 4, 5 ];Console.log(arr.last(2)); // 4,5 Share HTML | BBCode | Direct Link