angular copy vs cust js cloning (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>

<script>
  var obj = {
   a: 1,
   b: 2,
   c: 3,
   d: 4,
   e: 5,
   f: function() {
    return 6;
   },
   g: [7, 8, 9]
  };

extend = function(obj) {
        var clone, i;
        clone = {};
        for (i in obj) {
          if (typeof obj[i] === "object" && obj[i] !== null) {
            clone[i] = extend(obj[i]);
          } else {
            clone[i] = obj[i];
          }
        }
        return clone;
      };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
cust js
extend(obj);
ready
AngularJS – .copy()
angular.copy(obj, {});
ready

Revisions

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