Skip to content

实现JavaScript中的5种主要的数据类型(包括Number、String、Object、Array、Boolean)进行值复制 #6

@zuobaiquan

Description

@zuobaiquan
 Object.prototype.clone = function(){
            var o = this.constructor === Array ? [] : {};
            for(var e in this){
                    o[e] = typeof this[e] === "object" ? this[e].clone() : this[e];
            }
            return o;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions