标签:
1 function Person() { 2 this.name = ‘Anis‘; 3 } 4 Person.prototype.showName = function () { 5 alert(this.name); 6 }; 7 8 var p1 = new Person(); 9 // p1.showName(); 10 11 12 extend(PerJob.prototype, Person.prototype) 13 function PerJob() { 14 Person.call(this); // 调用父类的构造函数 15 16 this.job = ‘code‘; 17 } 18 19 function extend(subClass, parentClass) { 20 for (var i in parentClass) { 21 subClass[i] = parentClass[i]; 22 } 23 } 24 var p2 = new PerJob(); 25 p2.showName()
标签:
原文地址:http://www.cnblogs.com/Zhui/p/5403898.html