(function(){
(function(){
console.log(123);
}());
setTimeout(arguments.call,1000);
}());
//123
for(var i=0;i<3;i++){
setTimeout(function(){
console.log(i);
},0);
}
//3,3,3
function add(a,b){
alert(a+b);
}
function sub(a,b){
alert(a-b);
}
add.call(sub,3,1);
// 4
var x=20;
var a={
x:15,
fn:function(){
var x=30;
return function(){
return this.x;
}
}
}
console.log("a.fn():", a.fn());
console.log("(a.fn())():",(a.fn())());
console.log("a.fn()()", a.fn()());
console.log(a.fn.call(this));
console.log(a.fn().call(a));
/*
a.fn(): function (){
return this.x;
}
(a.fn())(): 20
a.fn()() 20
function (){
return this.x;
}
15
* */