方括号和点号效率差别

JavaScript performance comparison

Test case created

Info

var a = {a1: 1, a2: 2, a3: 3};

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = {a1: 1, a2: 2, a3: 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
square
var a1 = a["a1"];
var a2 = a["a2"];
var a3 = a["a3"];
pending…
dot
var a1 = a.a1;
var a2 = a.a2;
var a3 = a.a3;
pending…
ddd
f =1;
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