Is there a way to efficiently remove the first array element without modifying the original array (immutable)? I have this code snippet:
function getArray(): number[] {
return [1, 2, 3, 4, 5];
}
function getAnother(): number[] {
const [first, ...rest] = getArray();
return rest;
}
While the code works as intended, TypeScript check reported the following warning:
'first' is assigned a value but never used @typescript-eslint/no-unused-vars
Are there more elegant or better ways to achieve the same functionality as in getAnother()
?