Lodash each vs object keys

Benchmark created by Stanislav on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>

Setup

var obj = {
      "test1": 1,
      "test2": {},
      x: 100,
      y: 900,
      someTime: "sad"
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Lodash each
_.each(obj, function(v, k) {
  return k
})
ready
Object keys
Object.keys(obj).forEach(function(key) {
  return obj[key]
})
ready
Combine
_.each(Object.keys(obj), function(key) {
  return obj[key]
})
ready
For-of
for (var name of Object.keys(obj)) {
        obj[name]       
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.