this關鍵字

1、      在JavaScript的變量作用域裏有一條規則「全局變量都是window對象的屬性」。當執行 checkThis() 時相當於 window.checkThis(),因此,此時checkThis函數體內的this關鍵字的指向變成了window對象,而又因爲window對象有一個x屬性( 'this is a property of window'),所以會彈出 'this is a
相關文章
相關標籤/搜索