📜  链表 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:06.493000             🧑  作者: Mango

代码示例1
class LinkedList {
    constructor(head = null) {
        this.head = head
    }
}

class ListNode {
    constructor(value,next=null){
        this.value = value;
        this.next = next;
    };
}

let node1 = new ListNode(2);
let node2 = new ListNode(4);
node1.next = node2;

let list = new LinkedList(node1);

console.log(list.head.next);