obj:{
}
}
}
Let's say it can go N deep, how to do iterate over this object without using recursion?
use recursion
let obj = { obj: { obj: { value: "hi" } } }; while (!obj.value) { obj = obj.obj; } console.log(obj.value);
Also, it's not iteration, but traversal
You can use a loop. Why don't you want to use recursion tho?
Обсуждают сегодня