SOURCE

let makeIterator = function(array) {
    let nextIndex = 0;
    return {
        next: function() {
            return nextIndex < array.length ? 
            { value: array[nextIndex++], done: false} :
            { value: undefined, done: true}
        }
    }
}

let a = makeIterator([1,3,5,3]);
console.log(a.next().value);
console.log(a.next().value);
console 命令行工具 X clear

                    
>
console