jslitmus

Christian Harms's picture

JavaScript Object Access Micro benchmarks

After getting the tip to use JSLitmus for JavaScript microbenchmarks I grabbed my old "How to access JavaScript Object" code and build some tests with JSLitmus. The following question was sometimes very religious and only benchmarks can solve the problem:

The question is simple: what is faster?

  1. obj = {a:1};
  2.  
  3. //variant 1
  4. result = obj.a;
  5.  
  6. //variant 2
  7. result = obj['a'];
  8.  
  9. //variant 3 - build an object with getter function:
  10. result = obj.getA();
Read more

Syndicate content