转自:http://rangercyh.blog.51cto.com/1444712/1615809?utm_source=tuicool&utm_medium=referral
|
1
2
3
4
5
6
7
|
var a = { v : 0, f : function(xx) { this.v = xx; }}a.f(5); |
|
1
2
3
4
|
function f(xx) { this.x = xx;}f(5); |
|
1
2
3
4
|
function a(xx) { this.m = xx;}var b = new a(5); |
|
1
2
3
4
5
6
7
|
function a(xx) { this.b = xx;}var o = {};a.apply(o, [5]);alert(a.b); // undefinedalert(o.b); // 5 |
|
1
2
3
4
5
6
7
|
function a(xx, yy) { alert(xx, yy); alert(this); alert(arguments);}a.apply(null, [5, 55]);a.call(null, 5, 55); |
|
1
2
3
4
5
6
7
8
9
10
|
var m = { "x" : 1};function foo(y) { alert(this.x + y);}foo.apply(m, [5]);foo.call(m, 5);var foo1 = foo.bind(m, 5);foo1(); |
|
1
|
function jam() {}; |
|
1
|
var jam = function() {}; |
|
1
|
function jam() {}(); |
|
1
|
(function jam() {}()); |