题目描述
从头到尾打印一个链表
//定义一个链表
var lian = {
count: 3,
head: {
value: 1,
next: {
value: 2,
next: {
value: 3,
next: null,
}
}
}
}
function printf(l) {
var current = l.head;
while (current != null) {
console.log(current.value);
current = current.next;
}
}
printf(lian);