Array.prototype.values = function(){ let i = 0; let self = this return { next(){ const done = i>= self.length const value = done? undefined : self[i++] return { value, done } } } } const color = [‘red‘,‘green‘,‘white‘]; //控制台 color.values() color.next() 输出……xxx 自己尝试一下把
原文地址:https://www.cnblogs.com/jwzhang/p/12105160.html
时间: 2024-10-16 01:28:06