obj ={ 'a':1, 'b':2, 'c':3 } arr =[1,2,3,5] console.log(obj) for( key of arr) { console.log(key) } obj[Symbol.iterator] = function () { let aa = Object.values( obj ) //获取对象所有的值以数组返回 // console.log( aa,'aa' ) let index = 0 return { //a:123 next:function(){ if( index >= aa.length ){ return { value:undefined,done:true } }else{ return { value:aa[index++],done:false } } } } } for( key of obj) { console.log(key) }