javascript继承的两种方式
1,
1 <script type="text/javascript"> 2 function A() 3 { 4 this.name='a'; 5 } 6 function B() 7 { 8 9 } 10 11 12 B.prototype=new A(); 13 var obj=new B(); 14 15 alert(obj.name); 16 </script>
2,
1 <script type="text/javascript"> 2 function A() 3 { 4 this.name='a'; 5 } 6 function B() 7 { 8 A.call(this); 9 } 10 11 var obj=new B(); 12 13 alert(obj.name); 14 </script>