前端奇葩题!!!!!


(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
* */

posted on 2017-04-26 15:03  _chuck  阅读(254)  评论(0编辑  收藏  举报

导航