标签:克隆 animal nbsp return var asc color 支持 prot
var animal=function(){ this.blood=100; this.attackLevel=1; this.defenseLevel=1; }; var a=new animal(); a.blood=1000; a.attackLevel=15; a.defenseLevel=9; //调用克隆方法 var cloneAnimal=Object.create(a); console.log(cloneAnimal);//输出:Object{blood:1000,attackLevel:15,defenseLevel:9}
Object.create=Object.create||function(obj){ var F=function(){}; F.prototype=obj; return new F(); }
标签:克隆 animal nbsp return var asc color 支持 prot
原文地址:http://www.cnblogs.com/meiyh/p/6424478.html