const obj = {
store:['foo','bar','gba'],
[Symbol.iterator]:function(){
let index = 0
const self = this
return{
next:function(){
const result = {
value:self.store[index],
done:index>=self.store.length
}
index++
return result;
}
}
}
}
for(const item of obj){
console.log(item);
}
网友评论