首页 »Javascript教程 » javascriptwindow:Javascript 陷阱 window全局对象 »正文javascriptwindow:Javascript 陷阱 window全局对象来源: 发布时间:星期四, 2008年12月25日 浏览:33次 评论:0
function Test
![]() this.name='Test'; var name=2; this.show=function ![]() alert(name); alert(this.name);//显示名字 } } var test= ![]() ![]() ![]() test.show ![]() function Test2 ![]() this.name='Test2'; this.show=function ![]() alert(name); alert(this.name); } } Test ![]() ![]() ![]() var test2= ![]() ![]() test2.show ![]() ![]() ![]() alert(name); window.show ![]() ![]() //依次输出2,Test;Test,Test2;Test;2,Test // ff和ie6下都是同样 ![]() // 注意到:对象思路方法访问其对象 ![]() ![]() // 整个页面是默认 ![]() ![]() ![]() ![]() ![]() ![]() //直接直接 ![]() ![]() ![]() ![]() ![]() ![]() //window对象,this.name='Test'就是为window对象加了 ![]() // 那么当思路方法局部作用域内未定义name且 ![]() ![]() ![]() /*啊 ![]() ![]() ![]() ![]() 0
相关文章
读者评论发表评论 |
|