Skip to content

Array

first

Array<T>.prototype.first(): T

Returns the first item of an array

const arr = [1,2,3,4,5];
const first = arr.first(); // => 1

last

Array<T>.prototype.last(): T

Returns the last item of an array

const arr = [1,2,3,4,5];
const last = arr.last(); // => 5

secondLast

Array<T>.prototype.secondLast(): T

Returns the second last item of an array

const arr = [1,2,3,4,5];
const first = arr.secondLast(); // => 4