zoukankan      html  css  js  c++  java
  • 深度拷贝

    const isObject = function(obj) {
      if (obj === null || obj === undefined) return false;
      if (typeof obj === "object") return true;
    };
    
    const isArray = function(arr) {
      return Array.isArray(arr);
    };
    
    const deepClone = function(obj) {
      if (!isObject(obj)) return obj;
      let cloneObj = isArray(obj) ? [] : {};
      for (let key in obj) {
        if (obj.hasOwnProperty(key)) {
          let value = obj[key];
          if (isObject(value)) {
            cloneObj[key] = deepClone(value);
          } else {
            cloneObj[key] = value;
          }
        }
      }
      return cloneObj;
    };

    分别对extend 和 clone 库进行了性能测试比对... 发现extend 贼牛逼

    源码分析 : extend

  • 相关阅读:
    数据库练习
    pymysql
    数据库索引
    数据库查询
    数据库操作
    数据库建表
    数据库初识
    shell 编程
    Struts2与SpringMVC
    SpringAOP
  • 原文地址:https://www.cnblogs.com/mooniitt/p/8288455.html
Copyright © 2011-2022 走看看