Test name | Executions per second |
---|---|
for-in | 121.2 Ops/sec |
Object.keys | 103.8 Ops/sec |
var obj = {};
for (var i = 10000; i > 0; i--) {
obj[`key ${i}`] = i;
}
for (var key in obj) {
console.log(obj[key]);
}
Object.keys(obj).forEach(key => console.log(obj[key]));