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>

 

 

相关文章:

  • 2022-01-09
  • 2022-02-21
  • 2018-03-23
  • 2021-09-14
  • 2021-07-31
  • 2022-12-23
  • 2021-09-26
  • 2019-07-09
猜你喜欢
  • 2021-10-03
  • 2022-02-21
  • 2022-01-27
  • 2021-08-06
  • 2021-10-28
  • 2022-12-23
相关资源
相似解决方案