双向链表的优点:无论给出那个节点,都能对整个链表进行遍历
双向链表的缺点,多耗费一个引用空间,而且构建双向链表比较复杂
function Node(value){
this.value = value;
this.value.next = null;
this.value.prev = null;
}
let node1 = new Node(1)
let node2 = new Node(2)
let node3 = new Node(3)
let node4 = new Node(4)
let node5 = new Node(5)
node1.next = node2;
node2.prev = node1;
node2.next = node3;
node3.prev = node2;
node3.next = node4;
node4.prev = node3;
node4.next = node5;
node5.prev = node4;