Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36
Chrome 90
Linux
Desktop
3 years ago
Test name Executions per second
lodash 21211.6 Ops/sec
own 21574.4 Ops/sec
HTML Preparation code:
AخA
 
1
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js'></script>
Script Preparation code:
x
 
class Foo {
}
function objectCopy(object) {
  if (!object) {
    return {};
  }
  const copyObject = {};
  for (const attribute in object) {
    if (Array.isArray(object[attribute])) {
      copyObject[attribute] = arrayCopy(object[attribute]);
      continue;
    }
    if (object[attribute] instanceof Object) {
      copyObject[attribute] = objectCopy(object[attribute]);
      continue;
    }
    copyObject[attribute] = object[attribute];
  }
  return copyObject;
}
function arrayCopy(array) {
  if (!array) {
    return [];
  }
  const copyArray = [];
  for (let i = 0; i < array.length; i++) {
    if (Array.isArray(array[i])) {
      copyArray[i] = arrayCopy(array[i]);
      continue;
    }
    if (array[i] instanceof Object) {
      copyArray[i] = objectCopy(array[i]);
      continue;
    }
    copyArray[i] = array[i];
  }
  return copyArray;
}
var user = {
  name: "Teszt Elek",
  address: {
    country: "Magyarország",
    county: "Borsod-Abaúj-Zemplém megye",
    city: "Miskolc",
    street: "Felsőruzsin",
    streetType: "körút",
    houseNumber: "21"
  },
  job: {
    professional: "Szoftverfejleszto",
    company: {
      name: "Evosoft Hungary Kft.",
      group: {
        department: {
          name: "O5",
          code: "O5",
          teams: [
            "1",
            "2",
            "3",
            "4"
          ],
        },
        team: {
          name: "4",
          members: [
            "Gipsz Jakab",
            "Teszt Elek",
            "John Doe",
            "Jane Doe",
            "Gipsz Jakab",
            "Teszt Elek",
            "John Doe",
            "Jane Doe",
            "Gipsz Jakab",
            "Teszt Elek",
            "John Doe",
            "Jane Doe",
            "Gipsz Jakab",
            "Teszt Elek",
            "John Doe",
            "Jane Doe",
            "Gipsz Jakab",
            "Teszt Elek",
            "John Doe",
            "Jane Doe"
          ],
          responibilityFor: {
            share: {
              file: "//Something.dat",
              binary: [
                [2],
                [3],
                [5],
                [55],
                [1623],
                [1],
                [0],
                [1024],
                [2],
                [3],
                [5],
                [55],
                [1623],
                [1],
                [0],
                [1024],
                [2],
                [3],
                [5],
                [55],
                [1623],
                [1],
                [0],
                [1024]
              ],
              data: {
                binary: [
                  [2],
                  [3],
                  [5],
                  [55],
                  [1623],
                  [1],
                  [0],
                  [1024],
                  [2],
                  [3],
                  [5],
                  [55],
                  [1623],
                  [1],
                  [0],
                  [1024],
                  [2],
                  [3],
                  [5],
                  [55],
                  [1623],
                  [1],
                  [0],
                  [1024]
                ],
                obj: {
                  vami: "vami",
                  hami: "hami",
                  dami: {
                    ini: "ini",
                    ani: {
                      ani: "ani"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Tests:
  • lodash

     
    _.cloneDeep(user)
  • own

     
    objectCopy(user)