Dot vs String

Benchmark created by Saravana on


Test runner

Ready to run.

Testing in
TestOps/sec
Dot
function getResult() {
    var x, y, z;

    // Define x, y but not z
    x = 1;
    y = 2;

    var result = {};

    result.a = 'a';
    result.b = 'b';

    if (x !== undefined) {
        result.x = x;
    }

    if (y !== undefined) {
      result.y = y;
    }

    if (z !== undefined) {
      result.z = z;
    }

    return result;
}


getResult();
ready
String
function getResult() {
    var x, y, z;

    // Define x, y but not z
    x = 1;
    y = 2;

    var result = {};

    result ['a'] = 'a';
    result ['b'] = 'b';

    if (x !== undefined) {
        result ['x'] = x;
    }

    if (y !== undefined) {
      result ['y'] = y;
    }

    if (z !== undefined) {
      result ['z'] = z;
    }

    return result;
}


getResult();
ready

Revisions

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

  • Revision 1: published by Saravana on