(val)
| 33 | } |
| 34 | |
| 35 | addAtTail(val) { |
| 36 | if (this.head === null) { |
| 37 | this.head = new Node(val); |
| 38 | this.tail = this.head; |
| 39 | } else { |
| 40 | this.tail.next = new Node(val); |
| 41 | this.tail.next.prev = this.tail; |
| 42 | this.tail = this.tail.next; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | addAtIndex(index, val) { |
| 47 | if (index === 0) this.addAtHead(val); |