1、object.keys
for (var key of Object.keys(someObject)) { console.log(key + ': ' + someObject[key]); }
2、使用 Generator 函数将对象重新包装成数组
function* entries(obj) { for (let key of Object.keys(obj)) { yield [key, obj[key]]; } } for (let [key, value] of entries(obj)) { console.log(key, '->', value); }