Iterator接口实现

function Iterator(array) {
    var nextIndex = 0;
    return {
        next: function () {
            return nextIndex < array.length ? { value: array[nextIndex++] } : { done: true }
        }
    }
}

function idMaker() {
    var index = 0;
    return {
        next: function () {
            return {
                value: index++,
                done: false
            }
        }
    }
}
上次更新:
Contributors: jingmin.jiang