Value check in Object (v3)

Revision 3 of this benchmark created by Amit on


Setup

var obj = {
    a: 'test1',
    b: 'test2'
  };

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
Object.keys(obj).forEach(function(key) {
  if (obj[key] == 'test1') {
    console.log('has test1');
  }
});
ready
for in
for (k in obj) {
  if (obj[k] == "test1")
    console.log('exists');
}
ready
Array some()
Object.keys(obj).some(function(k) {
  if (obj[k] === "test1") {
    console.log('has test1');
  }
});
ready

Revisions

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