<script type="text/javascript">
<!--
function test(){
this.a = 1;
alert(this);
}
test();
var t = new test();
alert(a);
//-->
</script>
问alert出来的内容分别是什么!
其实非常讨厌这一类的题目
本文通过一个具体的JavaScript代码示例探讨了`this`关键字的指向问题及变量作用域的相关概念,展示了在不同上下文中`this`的具体表现,并讨论了全局与局部变量的区别。
<script type="text/javascript">
<!--
function test(){
this.a = 1;
alert(this);
}
test();
var t = new test();
alert(a);
//-->
</script>
问alert出来的内容分别是什么!
其实非常讨厌这一类的题目
675
2146
1753
5732

被折叠的 条评论
为什么被折叠?