push(val) {
        let node = new Node(val);
        if (this.tail === null) {
            this.head = node;
            this.tail = node;
        }
        else {
            this.tail.next = node;
            node.prev = this.tail;
            this.tail = node;
        }
    }
// pushes to the end of the list (tail)
pushes to the end of the list (tail)
pushes to the end of the list ( tail )
push(val) {
        let node = new Node(val);
        if (this.tail === null) {
            this.head = node;
            this.tail = node;
        }
        else {
            this.tail.next = node;
            node.prev = this.tail;
            this.tail = node;
        }
    }
push ( val ) { let node = new Node ( val ) ; if ( this . tail === null ) { this . head = node ; this . tail = node ; } else { this . tail . next = node ; node . prev = this . tail ; this . tail = node ; } }
pushes to the end of the list (tail)
pushes to the end of the list ( tail )