Is there any way that I'm missing do this operation using destructuring an array. My Array
const arr1 = [1,2,3,4,5,6,7,8,9,10]
and I have a variable rest, arr2 and range=5. And I want first range which is 5 elements from the array and rest of the elements in rest variable. The way I try it to be
[arr2,...rest] = arr1
In this case, arr2 will have output 1 and rest have the rest of the array. Is there any way I can have first 5 elements in arr2
sliceit. But i don't think that it's possible with just destructuring.