HTML Preparation code:
AخA
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
Script Preparation code:
 
var bob = {
    name: "Bob",
    age: 32,
    lastName: "test",
    local: {there:"there"},
    test:{
      test:{
        test:"test"
      }
    }
  };
Tests:
  • vanila

     
    function cloneObject(obj) {
        if (obj === null || typeof obj !== 'object') {
            return obj;
        }
     
        var temp = obj.constructor(); // give temp the original obj's constructor
        for (var key in obj) {
            temp[key] = cloneObject(obj[key]);
        }
     
        return temp;
    }
    var bill = (cloneObject(bob));
  • JSON.parse

     
    var bill2 = (JSON.parse(JSON.stringify(bob)));
  • lodash

     
    var deep = _.cloneDeep(bob);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    vanila
    JSON.parse
    lodash

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Chrome 53 on Mac OS X 10.11.6
View result in a separate tab
Test name Executions per second
vanila 1143883.2 Ops/sec
JSON.parse 246639.2 Ops/sec
lodash 135253.9 Ops/sec