variable vs property writes

JavaScript performance comparison

Test case created by Joshua Piccari

Info

Write times for variables and object properties (both common and uncommon).

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var array = [1, 2, 3],
      variable = array.length,
      oddball = {
        test: 3
      };
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Variable
variable = 0
pending…
Property (common object)
array[0] = 0
pending…
Property (oddball object)
oddball.test = 0
pending…

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

Compare results of other browsers

0 comments

Add a comment