generator不怎么常用,有更好的轻喷。 Array.prototype.getReader2 = function () { let arr = this; function * name (len) { let index = 0; while (index < arr.length) { let end = index + len; len = yield arr.slice(index, end); index = end; } } let it; return { read (num = 1) { if (!it) { it = name(num); } let { value , done } = it.next(num); return done ? [] : value; } } }