let es6 = { edition:6, committee:"TC39", standard:"ECMA-262"};for (let e in es6) {console.log(e);}// edition// committee// standardfor (let e of es6) {console.log(e);}// TypeError: es6[Symbol.iterator] is not a function
解决方案1:
使用 Object.keys 将对象的键名生成一个数组,然后遍历这个数组
for (var key ofObejct.keys(someObject)) {console.log(key +': '+ someObejct[key])}