双向链表的优点:无论给出那个节点,都能对整个链表进行遍历
    双向链表的缺点,多耗费一个引用空间,而且构建双向链表比较复杂

    1. function Node(value){
    2. this.value = value;
    3. this.value.next = null;
    4. this.value.prev = null;
    5. }
    6. let node1 = new Node(1)
    7. let node2 = new Node(2)
    8. let node3 = new Node(3)
    9. let node4 = new Node(4)
    10. let node5 = new Node(5)
    11. node1.next = node2;
    12. node2.prev = node1;
    13. node2.next = node3;
    14. node3.prev = node2;
    15. node3.next = node4;
    16. node4.prev = node3;
    17. node4.next = node5;
    18. node5.prev = node4;