has a tree data structure; suppose there are five branches; now I need to find a node; the node is on the third layer of the first branch; how can the subsequent trees not be traversed after finding this node? That is, jump out of the whole recursion? I wrote a simple test and found that I couldn"t jump out of recursion
.var arr = [[1,2],[3,4]]
const deep = (arr) => {
for (let i = 0; i < arr.length; iPP) {
if (Array.isArray(arr[i])) {
deep(arr[i])
} else {
console.log(arr[i])
if (arr[i] === 2) return
}
}
}
deep(arr)
or is recursion itself uninterruptible?