1 //第一种
 2 function Demo(){
 3     var obj=new Object();
 4     obj.name="Yubaba";
 5     obj.age=12;
 6     obj.firstF=function(){
 7     }
 8     obj.secondF=function(){
 9     }
10     return obj;
11 }
12 
13 var one=Demo();
14 // 调用输出
15 document.write(one.age);

 1 //第二种
 2 function Demo(){
 3     this.name="Yubaba";
 4     this.age=12;
 5     this.firstF=function(){
 6     }
 7     this.secondF=function(){
 8     }
 9 }
10 
11 var one=new Demo
12 
13 // 调用输出
14 document.write(one.age);

 

相关文章:

  • 2022-01-24
  • 2021-07-19
  • 2022-01-13
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
  • 2022-01-21
猜你喜欢
  • 2021-08-26
  • 2021-11-26
  • 2021-05-23
  • 2021-07-13
  • 2021-07-20
  • 2022-01-29
  • 2021-08-02
相关资源
相似解决方案