Int vs String in obj

JavaScript performance comparison

Test case created by Josh

Preparation code

Benchmark.prototype.setup = function() {
    var intObj = { 001:'Hi', 002:'Hi', 003:'Hi', 004:'Hi', 005:'Hi', 006:'Hi', 007:'Hi', 008:'Hi', 009:'Hi', 010:'Hi' };
    var stringObj = { 'a':'Hi', 'b':'Hi', 'c':'Hi', 'd':'Hi', 'e':'Hi', 'f':'Hi', 'g':'Hi', 'h':'Hi', 'i':'Hi', 'j':'Hi' };

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
By Int
var x;
for (var i=0; i<10000; i++) {
  x = intObj[005];
By string
var y;
for (var s=0; s<10000; s++) {
  y = stringObj['e'];

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

Compare results of other browsers


Add a comment