function cloneObject(obj) {
    var o = obj.constructor === Array ? [] : {};
    for (var i in obj) {
        if (obj.hasOwnProperty(i)) {
            o[i] = typeof obj[i] === "object" ? cloneObject(obj[i]) : obj[i];
        }
    }
    return o;
}

 

posted on 2017-09-08 14:46  _linka  阅读(128)  评论(0编辑  收藏  举报