1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 |
var
x = 3; var
foo = { x: 2, baz: { x: 1, bar: function () { return
this .x; } } } var
go = foo.baz.bar; alert(go()); //3 alert(foo.baz.bar()); //1 |
1
2
3
4
5
6
7
8
9
10
11
12 |
var
x = 4, obj = { x: 3, bar: function () { var
x = 2; ( function () { var
x = 1; alert( this .x); })() } }; obj.bar(); //4 |
1
2
3 |
var
foo = function
bar() {alert( typeof
bar);}; alert( typeof
bar); //undefined ie8以下是function foo(); //function |
原文:http://www.cnblogs.com/positive/p/3586448.html