SOURCE

function range(min,max){
    return{
        get min(){return min;},
        get max(){return max;},
        includes: function(x){
            return min <=x && x <= max;
        },
        toString:function(){
            return "[" + min + "," + max + "]";
        },
        __iterator__: function(){
            let val = Math.ceil(min);
            return {
                next: function(){
                    if(val > max){
                        throw StopIteration;
                    }
                    return val++;
                }
            };
        }
    };
}

for(let i in range(1,10)) console.log(i);
console 命令行工具 X clear

                    
>
console