标签:job worker pre back 程序员 继承 alert call round
1 <script> 2 function person(name,sex) { 3 this.name=name; 4 this.sex=sex; 5 } 6 7 person.prototype.showName=function () { 8 alert(‘我的名字:‘+this.name); 9 } 10 person.prototype.showSex=function () { 11 alert(‘我的sex:‘+this.sex); 12 } 13 //--------------------------------------------------- 14 function worker(name,sex,job) { 15 person.call(this,name,sex); 16 this.job=job; 17 } 18 worker.prototype=person.prototype; 19 20 worker.prototype.showJob=function () { 21 alert(‘我的job:‘+this.job); 22 } 23 24 var p1=new person(‘blue‘,‘男‘); 25 p1.showName(); 26 p1.showSex(); 27 28 var p2=new worker(‘blue‘,‘男‘,‘程序员‘); 29 p2.showJob(); 30 </script>
标签:job worker pre back 程序员 继承 alert call round
原文地址:http://www.cnblogs.com/miaoxiaojiao/p/7651628.html