1var PeekingIterator = function (iterator) {2this.iterator = iterator;3this.curr = iterator.next();4};56PeekingIterator.prototype.peek = function () {7return this.curr;8};910PeekingIterator.prototype.next = function () {11let temp = this.curr;12this.curr = this.iterator.next();13return temp;14};1516PeekingIterator.prototype.hasNext = function () {17return this.curr > 0; // the input iterator return -100000000 when next() after it run out of members, instead of return undefined.18};