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