Given,
1 |
const arr = ['sports', 'cooking', 'sleeping', 'eating']; |
We can destructure our array by placing the array elements into variables we create:
1 |
const [first, second, ...remainingHobbies] = arr; |
first sports
second cooking
remainingHobbies [‘sleeping’, ‘eating’]