1function recurse(arr=[])
2{
3 // base case, to break the recursion when the array is empty
4 if (arr.length === 0) {
5 return;
6 }
7
8 // destructure the array
9 const [x, ...y] = arr;
10
11 // Do something to x
12
13 return recurse(y);
14}