const obj = {
next: {
next: {
next: {
next: {
next: {
next: {
next: null
}
}
}
}
}
}
}
function walk(node) {
if (node) {
console.log(node);
walk(node.next);
}
}
function walk(node) {
while (node) {
console.log(node);
node = node.next;
}
}