<script type="text/javascript" >
function x() {
alert(2);
}
x();
var x = function () {
alert(0);
};
x();
var x = function () {
alert(1);
};
x();
function x() {
alert(3);
}
x();
//结果是弹出: 3 0 1 1
----------------------------------
if (!("a" in window)) {
var a = 1;
}
alert(a);//Rs: undefined
----------------------------------
var a = 1,
b = function a(x) {
x && a(-xx);
};
alert(a);//Rs: 1
----------------------------------
function a(x){
return x*2;
}
var a;
alert(a);//Rs: function a(x){ return x*2;}
----------------------------------
function b(x,y,a){
arguments[2] = 10;
alert(a);
}
b(1,2,3);//Rs: 10
----------------------------------
function test(x){
alert(x);
var x = 123;
function x(){
}
alert(x);
}
test(222);//Rs: function x(){} ,123
var obj = {
i : "test",
m : function(){
alert(this.i);//指向obj对象 ,值test
function B(){
var i = 1;
alert(this.i);//指向window对象,值undefined
}
B();
}
}
obj.m();//Rs: test , undefined
</script>