Object deep copy problem

You simply need a deep copy of the object can be passed in the following function

function deepCopy(obj) {
    if (typeof obj === 'object') {
        return JSON.parse(JSON.stringify(obj));
    } else {
        return obj;
    }
}

 

Guess you like

Origin www.cnblogs.com/kaiqinzhang/p/11082038.html