Array.prototype.getReader = function () { let i = 0 return { read: (n = 1) => { const res = this.slice(i, i + n) i += n return res } } } const arr = [1, 2, 3, 4, 5, 6] const reader = arr.getReader() console.log(reader.read()) console.log(reader.read(1)) console.log(reader.read(2)) console.log(reader.read(3)) console.log(reader.read()) console.log(arr)