如何让一个普通的对象变得可枚举
var obj = { a: 2, b: 3 }; Object.defineProperty(obj, Symbol.iterator, { enumerable: false, writable: false, configurable: true, value: function() { var self = this; idx = 0; var ks = Object.keys( self ); console.log(ks) return { next: function() { return { value: self[ks[idx++]], done: (idx > ks.length) } } } } }) for(let v of obj) { console.log(v); }