zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    uva 10099(最大生成树+搜索)
    Codeforces Round #218 (Div. 2) 解题报告
    CodeChef December Challenge 2013 解题报告
    Codeforces Round #217 (Div. 2) 解题报告
    uva 1423 (拓扑排序)
    UESTC 1307 windy数(数位DP)
    Codeforces Round #216 (Div. 2) 解题报告
    Codeforces Round #215 (Div. 2) 解题报告
    uva 10047(BFS)
    uva 10369(最小生成树)
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/1973300.html
Copyright © 2011-2022 走看看