We have an array [1,2,3]
and we want get the last 2 items on it, or [2,3].
Approach
const arr: number[] = [1, 2, 3];
const lasttwo = arr.slice(-2);
We have an array [1,2,3]
and we want get the last 2 items on it, or [2,3].
const arr: number[] = [1, 2, 3];
const lasttwo = arr.slice(-2);