return array with first value trimmed out in javascript

To return a new array with the first value trimmed out in JavaScript, you can use the slice() method. Here's an example:

index.tsx
const arr = ['apple', 'banana', 'cherry'];
const newArr = arr.slice(1);

console.log(newArr); // Output: ['banana', 'cherry']
126 chars
5 lines

The slice() method returns a new array starting from the specified index (1 in this case), removing the first element. The original array remains unchanged.

related categories

gistlibby LogSnag