jquery js解析函數、函數直接調用

來源:互聯網
上載者:User

標籤:ack   對象   div   func   範圍   調用   定義   not   query   

-----------------------------------------------------------------cc = function(){alert(345)},pushStack = function() {    cc();},pushStack();//345//沒加var的放在window對象中pushStack = function() {    cc();},cc = function(){alert(345)},pushStack();//345----------------------------------------------------------------pushStack = function() {    cc();//cc is not defined};pushStack();cc = function(){alert(345)};pushStack = function() {    cc();};pushStack();//345function cc(){alert(345)};----------------------------------------------------------------cc = function(){alert(345)};pushStack();//pushStack is not defined ,js解析器執行到這裡的時候pushStack還是未定義pushStack = function() {    cc(); };cc = function(){alert(345)};pushStack();//345,js解析器執行到這裡的時候pushStack已經定義了function pushStack() {    cc(); };

 

name = ‘2‘;a = function(){    alert(this.name);    alert(888);},o = {    fn1 : function(){            a = function(){             //fn1執行的時候(fn1要執行,不執行是加不進去的)把a加到window裡面去,把外部的a方法覆蓋了                alert(this.name);//2  window                alert(this);//2                alert(666);            };            a();//666  a.call(window)            window.a();//666    }}o.fn1();window.a();// 2   666

 

name = ‘2‘;a = function(){    alert(this.name);    alert(888);},o = {    fn1 : function(){            this.a = function(){//fn1執行,給o對象加了a方法                alert(this.name);                 alert(this);                alert(666);            };            a(); //2   888    a.call(window)   ,都是從window中找a()沒有就報錯            window.a(); //2  888    }}o.fn1();window.a();// 2   888
o.a();//666
name = ‘2‘;a = function(){    alert(this.name);    alert(888);},o = {    fn1 : function(){            var a = function(){ //fn1函數執行,就有2個a方法,一個在fn1局部範圍,一個在window                alert(this.name);                 alert(this);                alert(666);            };            a(); //2  666  a.call(window),尋找局部範圍的a方法            window.a(); // 2  888    }}o.fn1();window.a();//  2   888

 

jquery js解析函數、函數直接調用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.