var F=function(){
    this.a=""
    this.display=function(){
         alert("111111");
     }
}
这样一个对象是这么构造的。。
var f=new F(); 
然后再使用。。
如果现在要变成这样怎么办?
var E=function(){
    this.F=function(){
    this.a=""
    this.display=function(){
         alert("111111");
     }
}
}
要如何构造呢?

解决方案 »

  1.   

    其实就是我想把我写的2个对象整到一个大对象里。。然后再使用结果不知道怎么弄了
    var E=function(){ 
        this.F=function(){ 
          this.a="" 
          this.displayF=function(){ 
              alert("111111"); 
          } 
        }
       this.H=function(){ 
          this.b="" 
          this.displayH=function(){ 
              alert("2222222"); 
          } 
        }  
    } 我现在想适用F这个对象来完成alert("111111").要怎么做呢?
      

  2.   


    var E=function(){
        this.F={
          a:"",
          displayF:function(){
              alert("111111");
          }
        }
      this.H=function(){
          this.b=""
          this.displayH=function(){
              alert("2222222");
          }
        } 
    } var e = new E();
    e.F.displayF();
      

  3.   

    那如果F有参数呢???
    var E=function(){ 
        this.F=function(arg){ 
          this.a=arg; 
          this.displayF=function(){ 
              alert(this.a); 
          } 
        } 
      this.H=function(arg){ 
          this.b=arg 
          this.displayH=function(){ 
              alert(this.b); 
          } 
        }  

    这样怎么输出呢?
      

  4.   


    var E=function(){
        this.F={
          a:"",
          displayF:function(arg){
              alert(arg);
          }
        }
    } var e = new E();
    e.F.displayF("test");
      

  5.   

    var e = new E();
    e.F.displayF("test");
      

  6.   


    var E=function(){
        this.F=function(arg){       
            return {
              a:"",
              displayF:function(arg){
                  alert(arg);
              }
            }
        }
    } var e = new E();
    e.F().displayF("test");
      

  7.   

    是不是var E=function(){ 
        this.F=function(arg){ 
          this.a=arg; 
          this.displayF=function(){ 
              alert(this.a); 
          } 
        } 
      this.H=function(arg){ 
          this.b=arg 
          this.displayH=function(){ 
              alert(this.b); 
          } 
        }  
    } 这里面F不能带参数呢???
    如果要带参数就得拉到里面的函数上去传参数么?
      

  8.   


    var E=function(){
        this.F=function(arg){     
            return {
              a:"",
              displayF:function(){
                  alert(arg);
              }
            }
        }
    } var e = new E();
    e.F("test").displayF();
      

  9.   


    var E=function(){
        this.F = new F();
    } var F = function(){     
        this.a="";
        this.displayF=function(arg){
            alert(arg);
        }
    }var e = new E();
    e.F.displayF("test");
      

  10.   

    呵呵感谢LtnRain
    最后一种方法偶采纳了比较不错的说
    呵呵。。开始我自己也想到一个方法
    就是
    var E={};
    E.F=function(){     
        this.a="";
        this.displayF=function(arg){
            alert(arg);
        }
    }var f=new E.F();
    e.F.displayF("test");
    不过看了你的代码觉得你的貌似更好。。就决定采纳你的了
    分给你咯