javascript 谁才是initialize方法
view plaincopy to clipboardprint?
<mce:script type="text/javascript"><!--   
    var A = function()    
            {   
                this.initialize.apply(this , arguments);   
                //这里apply调用的是prototype中的initialize为什么不调用这个initialize而死循环呢?   
            };    
  
    A.prototype=   
    {   
        initialize:function(v){this.value=v;},   
        showValue:function(){alert(this.value);}   
    }   
  
    var a = new A('helloWord!');//实例化一个A的对象a   
       
    a.showValue("helloWorld");   
// --></mce:script>  
<mce:script type="text/javascript"><!--
 var A = function() 
   {
    this.initialize.apply(this , arguments);
    //这里apply调用的是prototype中的initialize为什么不调用这个initialize而死循环呢?
   }; 
 A.prototype=
 {
  initialize:function(v){this.value=v;},
  showValue:function(){alert(this.value);}
 }
 var a = new A('helloWord!');//实例化一个A的对象a
 
 a.showValue("helloWorld");
// --></mce:script> 
view plaincopy to clipboardprint?
 <mce:script type="text/javascript"><!--   
var A = function()    
        {   
            alert("here is befor this.initialize~!");   
            this.initialize.apply(this , arguments);   
            //这里只是指明委派给谁,并不是调用。   
            alert("here is after this.initialize~!");   
        };    
A.prototype=   
{   
    initialize:function(v){this.value=v;alert("here is prototype.initialize~! and the value is :"+this.value);},   
    showValue:function(){alert(this.value);}   
}   
var a = new A('helloWord!');//实例化一个A的对象a   
a.showValue("helloWorld");   
/ --></mce:script>  
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/nailwl/archive/2009/07/28/4386591.aspx
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号