js-深拷贝

js 深拷贝

    function deepCopy(source) {
        var sourceCopy = source instanceof Array ? [] : {};
        for (var item in source) {
            sourceCopy[item] = typeof source[item] === 'object' ? objDeepCopy(source[item]) : source[item];
        }
        return sourceCopy;
    }
posted @ 2023-02-02 10:58  过好每一天2022  阅读(26)  评论(0)    收藏  举报