分享几道经典的javascript面试题

这几道题目还是有一点意思的,大家可以研究一番,对自己的技能提升绝对有帮助。

1、调用过程中输出的内容是什么

function fun(n, o) {
    console.log(o);
    return {
        fun : function(m) {
            return fun(m, n);
        }
    }    
}

var a = fun(0);
a.fun(1);
a.fun(2);
a.fun(3);
var b = fun(0).fun(1).fun(2).fun(3);
var c = fun(0).fun(1);
c.fun(2);
c.fun(3);

2、console.log中的值是什么

var s = 3;
function test() {
    var s = 2;
    function f() {
        return s;
    }
    return f;
}
var test = test();
console.log(test);
var f =test();
console.log(f);

3、console.log中的值是什么

var arr = [];
function fun() {
    for(var i=0; i<4; i  ) {
        var x = {};
        x.no = i;
        x.test = arr[i];
        x.fun = function() {
            console.log(i);
        }
        arr.push(x);
    }
}
fun();
console.log(arr[0].fun());
console.log(arr[1].fun());
console.log(arr[2].fun());
console.log(arr[3].fun());

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值