几个javascript面试题

时间:14-02-25 栏目:Javascript 作者:zongyan86 评论:0 点击: 3,697 次

1.

var name = 'web开发分享';
function func() {
    var id = 'www.kuaipao8.com';
    function alertId() {
        alert(id);
    }
    alertId();
}
alert(name);
//答案:web开发分享
alert(id);
//答案:错误
func(); 
//答案:www.kuaipao8.com
alertId();
//答案:错误

2.

var a = 8;
setTimeout(function () {
    alert(a);
    a = 88;
}, 1000);
a = 888;

答案:888

3.

var value; 
var A = function() { 
    setTimeout(function() { 
        value = 10; 
    }, 200); 
} 
var B = function() { 
    alert(value); 
}

A();
B(); //答案:undefine

4.

 function test(obj1, obj2, obj3) {
    alert([].slice.call(arguments,2));
 }
 test("liwei", "liwei2","我开");
   答案:"我开"

5.

alert(0.1 + 0.2 === 0.3);

答案:false

web开发分享



声明: 本文由( zongyan86 )原创编译,转载请保留链接: 几个javascript面试题

关注我们