for-in vs Object.keys forEach without inherited properties
问题 I was looking at a perf benchmark of Object.keys + forEach vs for-in with normal objects. This benchmark shows that Object.keys + forEach is 62% slower than the for-in approach. But what if you don't want to get the inherited properties ? for-in includes all non-native inherited objects, so we'll have to use hasOwnProperty to check. I tried to make another benchmark here doing exactly that. But now the for-in approach is 41% slower than Object.keys + forEach . update The above test was done