很主要的一句,漏掉了。
“this关键字关联于执行时的作用域,而非定义时的作用域。”这句话怎么理解?能举个例子吗?

解决方案 »

  1.   

    http://www.blogjava.net/mxx/archive/2006/10/29/77919.html
    8.8. 函数作用域与闭包
    http://blog.csdn.net/haluomao/archive/2005/10/12/500954.aspx
    JavaScript中this关键字使用方法详解
      

  2.   

    http://www.never-online.net/blog/article.asp?id=117
      

  3.   

    this表示当前类的实例,理解当前类的实例就可以了,感觉跟VC的一样啊!
      

  4.   

    看下边的例子:function test()
    {
       this.testMethod = function(){alert(1);};
    }
    var testInstance = new test();
    testInstance.testMethod = function()
    {
       var testInstanceInner = new test();
       testInstance.testMethod = function()
       {
            alert(2);
       }
    }这样写就错了,我觉得是你说的那句话的原因,this是在执行中的作用于而非定义时的,可把我害惨了,有高手给个解决方案没?