链表断开连接
const head = {
'val':1,
'next':{
'val':2,
'next':{
'val':3,
'next':{
'val':4,
'next':{
'val':5,
'next':undefined
}
}
}
}
}
const breakList = function (node) {
while (node) {
// 获取next节点
next = node.next
node.next = null
console.log(node)
node = next
}
};
console.log(breakList(head))