Object native concatenation versus jQuery.extend()

JavaScript performance comparison

Test case created by Julien

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Native Js
mb = {
  prop1:1,
  prop2:2,
  method1: function method1(){
    return 1 + 1;
  },
  method2: function method2(){
    return 2 + 2;
  }
}

mb.prop3 = 3;
mb.prop4 = 4;
mb.method3 = function method3(){
  return 3 + 3;
};
mb.method4 = function method4(){
  return 4 + 4;
}
pending…
jQuery.extend
mb = {
  prop1:1,
  prop2:2,
  method1: function method1(){
    return 1 + 1;
  },
  method2: function method2(){
    return 2 + 2;
  }
}

mb2 = {
  prop3:3,
  prop4:4,
  method3: function method3(){
    return 3 + 3;
  },
  method4: function method4(){
    return 4 + 4;
  }
}

jQuery.extend(mb, mb2);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment