deep copy object (without functions)

Benchmark created on


Setup

const t = [
  {
    "URL": "https://www.toyotaofmurfreesboro.com/searchused.aspx",
    "prod": {
      "assetsCalls": ["pix-aop.min.js", "dealer-on.min.js"],
      "assetsCallCount": 2,
      "configResponseCode": 200,
      "configWsp": "DealerOn",
      "configCallCount": 1,
      "pageLoadPayload": {
        "program": "",
        "dealerCode": "toyotaofmurfheesboro",
        "wspCode": "DealerOn",
        "pageType": "vlp",
        "experimental": {
          "version": ["1.27.3"]
        },
        "fullUrl": "https://www.toyotaofmurfreesboro.com/searchused.aspx",
        "rank": "",
        "titlePage": "All Used Car Inventory | Toyota of Murfreesboro"
      },
      "pageLoadCallCount": 1,
      "pageWsp": "DealerOn",
      "wspMatch": true,
      "qaapi": {
        "hits": [],
        "visit": {
          "result": [],
          "warnings": []
        },
        "offset": 0
      },
      "vdps": [
        {
          "assetsCalls": ["pix-aop.min.js", "dealer-on.min.js"],
          "assetsCallCount": 2,
          "configResponseCode": 200,
          "configWsp": "DealerOn",
          "configCallCount": 1,
          "pageLoadPayload": {
            "program": "",
            "dealerCode": "toyotaofmurfheesboro",
            "wspCode": "DealerOn",
            "pageType": "vdp",
            "vehicleType": "Used",
            "year": "2013",
            "make": "Toyota",
            "model": "Prius c",
            "bodyStyle": "5D Hatchback",
            "stockNumber": "P10159",
            "vin": "JTDKDTB39D1038557",
            "price": "14362",
            "fuelEconomy": "53mpg city, 46mpg hwy",
            "odometer": "103300 mi",
            "exteriorColor": "Orange",
            "experimental": {
              "json_ld": ["vehicleType,model,stockNumber,vin,exteriorColor,year,price,make"],
              "HTML_data": ["bodyStyle,fuelEconomy,odometer"],
              "version": ["1.27.3"]
            },
            "fullUrl": "https://www.toyotaofmurfreesboro.com/used-Murfreesboro-2013-Toyota-Prius+c-Two-JTDKDTB39D1038557",
            "rank": "",
            "titlePage": "2013 Toyota Prius c Two Near Nashville | JTDKDTB39D1038557"
          },
          "pageLoadCallCount": 1,
          "pageWsp": "DealerOn",
          "wspMatch": true,
          "qaapi": {
            "hits": [],
            "visit": {
              "result": [],
              "warnings": []
            },
            "offset": 0
          },
          "url": "https://www.toyotaofmurfreesboro.com/used-Murfreesboro-2013-Toyota-Prius+c-Two-JTDKDTB39D1038557"
        }
      ]
    },
    "nonProd": {
      "assetsCalls": ["pix-aop.min.js"],
      "assetsCallCount": 1,
      "configResponseCode": 200,
      "configWsp": "DealerOn",
      "configCallCount": 1,
      "pageLoadPayload": {
        "program": "",
        "dealerCode": "toyotaofmurfheesboro",
        "wspCode": "DealerOn",
        "pageType": "vlp",
        "experimental": {
          "version": ["1.27.3-SNAPSHOT-1663163915"]
        },
        "fullUrl": "https://www.toyotaofmurfreesboro.com/searchused.aspx",
        "rank": "",
        "titlePage": "All Used Car Inventory | Toyota of Murfreesboro"
      },
      "pageLoadCallCount": 1,
      "pageWsp": "DealerOn",
      "wspMatch": true,
      "qaapi": {
        "hits": [
          {
            "rawHit": {
              "result": {
                "hitUuid": "9b5150b4-b583-4daf-a06a-24538641a74e",
                "visitorId": "GHP5TgwfHt7a8oBtVtd76ejg",
                "eventTimestamp": 1663748411158,
                "rawPayload": "http://pixall-qa.esm1.net/v2/pageload?p=&v=RWbXmB7SbJxz8neiVCk3JjVT&d=toyotaofmurfheesboro&w=DealerOn&pt=vlp&x=version%3D1.27.3-SNAPSHOT-1663163915&u=https://www.toyotaofmurfreesboro.com/searchused.aspx&rn=51673830544&r=&t=All+Used+Car+Inventory+%7C+Toyota+of+Murfreesboro",
                "rawHeaders": "Timeout-Access: <function1>\nX-Forwarded-For: 204.193.152.32, 23.1.32.212, 184.29.141.77\nX-Forwarded-Proto: https\nX-Forwarded-Port: 443\nHost: pixall-qa.esm1.net\nX-Amzn-Trace-Id: Root=1-632ac93b-279f182551858c2a3d36c5ea\nPragma: no-cache\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36\nAccept: image/avif, image/webp, image/apng, image/svg+xml, image/*, */*;q=0.8\nsec-fetch-site: cross-site\nsec-fetch-mode: no-cors\nsec-fetch-dest: image\nReferer: https://www.toyotaofmurfreesboro.com/\nAccept-Language: it-IT, it;q=0.9\nCookie: pxa_ssn=1; abc=GHP5TgwfHt7a8oBtVtd76ejg; akaalb_pixall_nonprod=1663750162~op=ddc_ana_pixall_nonprod:eng_ana_pixall_nonprod-pico-us-west-2|~rv=47~m=eng_ana_pixall_nonprod-pico-us-west-2:0|~os=a92128471d2f7f62621a51a133bf3e6f~id=1e88271755d4f7ca4b229a1913bf2478\nX-Akamai-SR-Hop: 1\nTrue-Client-IP: 204.193.152.32\nX-AKA-NIM-ALB-ARL-ORIGIN-SET-BY: ALB:pixall_nonprod\nX-AKA-NIM-ALB-ARL-ORIGIN-ID: eng_ana_pixall_nonprod-pico-us-west-2\nX-AKA-NIM-ALB-FWD-GTM-ORIGIN: ddc_ana_pixall_nonprod\nX-Akamai-CONFIG-LOG-DETAIL: true\nAccept-Encoding: gzip\nAkamai-Origin-Hop: 2\nVia: 1.1 v1-akamaitech.net(ghost) (AkamaiGHost), 1.1 akamai.net(ghost) (AkamaiGHost)\nCache-Control: no-cache, max-age=0"
              },
              "warnings": []
            },
            "sessionizedRawHit": {
              "result": {
                "payload": "http://pixall-qa.esm1.net/v2/pageload?p=&v=RWbXmB7SbJxz8neiVCk3JjVT&d=toyotaofmurfheesboro&w=DealerOn&pt=vlp&x=version%3D1.27.3-SNAPSHOT-1663163915&u=https://www.toyotaofmurfreesboro.com/searchused.aspx&rn=51673830544&r=&t=All+Used+Car+Inventory+%7C+Toyota+of+Murfreesboro",
                "headers": "Timeout-Access: <function1>\nX-Forwarded-For: 204.193.152.32, 23.1.32.212, 184.29.141.77\nX-Forwarded-Proto: https\nX-Forwarded-Port: 443\nHost: pixall-qa.esm1.net\nX-Amzn-Trace-Id: Root=1-632ac93b-279f182551858c2a3d36c5ea\nPragma: no-cache\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36\nAccept: image/avif, image/webp, image/apng, image/svg+xml, image/*, */*;q=0.8\nsec-fetch-site: cross-site\nsec-fetch-mode: no-cors\nsec-fetch-dest: image\nReferer: https://www.toyotaofmurfreesboro.com/\nAccept-Language: it-IT, it;q=0.9\nCookie: pxa_ssn=1; abc=GHP5TgwfHt7a8oBtVtd76ejg; akaalb_pixall_nonprod=1663750162~op=ddc_ana_pixall_nonprod:eng_ana_pixall_nonprod-pico-us-west-2|~rv=47~m=eng_ana_pixall_nonprod-pico-us-west-2:0|~os=a92128471d2f7f62621a51a133bf3e6f~id=1e88271755d4f7ca4b229a1913bf2478\nX-Akamai-SR-Hop: 1\nTrue-Client-IP: 204.193.152.32\nX-AKA-NIM-ALB-ARL-ORIGIN-SET-BY: ALB:pixall_nonprod\nX-AKA-NIM-ALB-ARL-ORIGIN-ID: eng_ana_pixall_nonprod-pico-us-west-2\nX-AKA-NIM-ALB-FWD-GTM-ORIGIN: ddc_ana_pixall_nonprod\nX-Akamai-CONFIG-LOG-DETAIL: true\nAccept-Encoding: gzip\nAkamai-Origin-Hop: 2\nVia: 1.1 v1-akamaitech.net(ghost) (AkamaiGHost), 1.1 akamai.net(ghost) (AkamaiGHost)\nCache-Control: no-cache, max-age=0",
                "hitUuid": "9b5150b4-b583-4daf-a06a-24538641a74e",
                "visitorId": "GHP5TgwfHt7a8oBtVtd76ejg",
                "eventTimestamp": 1663748411158,
                "sessionId": "9b5150b4-b583-4daf-a06a-24538641a74e",
                "sessionTimestamp": 1663748411158
              },
              "warnings": []
            },
            "parsedHit": {
              "result": {
                "sessionId": "9b5150b4-b583-4daf-a06a-24538641a74e",
                "visitorId": "GHP5TgwfHt7a8oBtVtd76ejg",
                "hitUuid": "9b5150b4-b583-4daf-a06a-24538641a74e",
                "eventTimestamp": 1663748411158,
                "sessionTimestamp": 1663748411158,
                "url": "https://www.toyotaofmurfreesboro.com/searchused.aspx",
                "urlParams": {},
                "experimental": {
                  "version": "1.27.3-SNAPSHOT-1663163915"
                },
                "dealerCode": "toyotaofmurfheesboro",
                "accountId": "toyotaofmurfheesboro",
                "wspCode": "DealerOn",
                "headers": "",
                "payload": "",
                "ipv4": "204.193.152.32",
                "domain": "toyotaofmurfreesboro.com",
                "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
                "pageType": "vlp",
                "program": "",
                "formConversion": false,
                "r1QueryParam": "",
                "titleTag": "All Used Car Inventory | Toyota of Murfreesboro",
                "adGroup": "toyotaofmurfheesboro",
                "esmUserId": "GHP5TgwfHt7a8oBtVtd76ejg",
                "isBot": false,
                "hitType": "page-view",
                "device": "Personal computer",
                "thirdPartyPixallBlocked": false,
                "pxaId": "RWbXmB7SbJxz8neiVCk3JjVT",
                "lostAndFound": {}
              },
              "warnings": []
            }
          }
        ],
        "visit": {
          "result": [
            {
              "visitUuid": "9b5150b4-b583-4daf-a06a-24538641a74e",
              "visitorId": "GHP5TgwfHt7a8oBtVtd76ejg",
              "program": "",
              "accountId": "toyotaofmurfheesboro",
              "domain": "toyotaofmurfreesboro.com",
              "startTimestamp": 1663748411158,
              "sessionTimestamp": 1663748411158,
              "endTimestamp": 1663748411158,
              "formSubmissionCount": 0,
              "vdpViewCount": 0,
              "pageViewCount": 1,
              "vlpViewCount": 1,
              "homeViewCount": 0,
              "showroomViewCount": 0,
              "financeViewCount": 0,
              "aboutViewCount": 0,
              "partsViewCount": 0,
              "comparisonViewCount": 0,
              "specialsViewCount": 0,
              "otherViewCount": 0,
              "errorViewCount": 0,
              "serviceViewCount": 0,
              "contactViewCount": 0,
              "directionsViewCount": 0,
              "favoritesViewCount": 0,
              "dealerCode": "toyotaofmurfheesboro",
              "wspCode": "DealerOn",
              "formSubmissions": [],
              "userAgentRaw": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
              "userAgentType": "Browser",
              "ipv4": "204.193.152.32",
              "device": "Personal computer",
              "browserName": "Chrome",
              "browserVersion": "104.0.0.0",
              "operatingSystemName": "Linux",
              "operatingSystemVersion": "",
              "myCarsEnabled": false,
              "vehicleSaveCount": 0,
              "vehicleNotificationsEnabledCount": 0,
              "userRegistrationCount": 0,
              "pageViews": [
                {
                  "hitUuid": "9b5150b4-b583-4daf-a06a-24538641a74e",
                  "url": "https://www.toyotaofmurfreesboro.com/searchused.aspx",
                  "pageType": "vlp",
                  "isManagedServices": false,
                  "time": 1663748411158,
                  "tracked": false
                }
              ],
              "contentEvents": [],
              "landingUrl": "https://www.toyotaofmurfreesboro.com/searchused.aspx",
              "isBot": false,
              "isBlockedIpv4": false,
              "financeDriverInitiated": false,
              "tradeDriverInitiated": false,
              "paymentDriverInitiated": false,
              "reserveItNowInitiated": false,
              "listingImpressions": [],
              "isAkamaiBot": false,
              "isFlagged": false,
              "myCarsUserEvents": [],
              "referrerOverride": "DIRECT",
              "isPersonalized": false,
              "thirdPartyPixallBlocked": false,
              "modelDetailsViewCount": 0,
              "paymentEstimatorViewCount": 0,
              "buildPriceViewCount": 0,
              "findDealerViewCount": 0
            }
          ],
          "warnings": []
        },
        "offset": 1
      },
      "vdps": [
        {
          "assetsCalls": ["pix-aop.min.js", "dealer-on.min.js"],
          "assetsCallCount": 2,
          "configResponseCode": 200,
          "configWsp": "DealerOn",
          "configCallCount": 1,
          "pageLoadPayload": {
            "program": "",
            "dealerCode": "toyotaofmurfheesboro",
            "wspCode": "DealerOn",
            "pageType": "vdp",
            "vehicleType": "Used",
            "year": "2013",
            "make": "Toyota",
            "model": "Prius c",
            "bodyStyle": "5D Hatchback",
            "stockNumber": "P10159",
            "vin": "JTDKDTB39D1038557",
            "price": "14362",
            "fuelEconomy": "53mpg city, 46mpg hwy",
            "odometer": "103300 mi",
            "exteriorColor": "Orange",
            "experimental": {
              "json_ld": ["vehicleType,model,stockNumber,vin,exteriorColor,year,price,make"],
              "HTML_data": ["bodyStyle,fuelEconomy,odometer"],
              "version": ["1.27.3"]
            },
            "fullUrl": "https://www.toyotaofmurfreesboro.com/used-Murfreesboro-2013-Toyota-Prius+c-Two-JTDKDTB39D1038557",
            "rank": "",
            "titlePage": "2013 Toyota Prius c Two Near Nashville | JTDKDTB39D1038557"
          },
          "pageLoadCallCount": 1,
          "pageWsp": "DealerOn",
          "wspMatch": true,
          "qaapi": {
            "hits": [],
            "visit": {
              "result": [],
              "warnings": []
            },
            "offset": 0
          },
          "url": "https://www.toyotaofmurfreesboro.com/used-Murfreesboro-2013-Toyota-Prius+c-Two-JTDKDTB39D1038557"
        }
      ]
    }
  }
]

Test runner

Ready to run.

Testing in
TestOps/sec
deepcopy json.parse
JSON.parse(JSON.stringify(t));
ready
deepcopy custom function
function deepCopy(o) {
  let newobject = {};
  if (o !== undefined && o !== null && o.constructor)
    newobject = new o.constructor();
  return typeof o === 'object' && o !== null ?      // only clone objects
    (Array.isArray(o) ?                        // if cloning an array
        o.map(e => deepCopy(e)) :                   // clone each of its elements
        Object.keys(o).reduce(                   // otherwise reduce every key in the object
          (r, k) => (r[k] = deepCopy(o[k]), r), newobject  // and save its cloned value into a new object
        )
    ) :
    o;                                         // return non-objects as is
}
deepCopy(t)
ready

Revisions

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