JS变量提升题集

1、 console.log(a);
var a=12;
function fn(){
console.log(a);
var a=13;
}
fn();
console.log(a);
输出的三次分别是多少
A、undefined 12 13 B、undefined undefined 12
C、undefined undefined 13 D、有程序报错

2、console.log(a);
var a=12;
function fn(){
console.log(a);
a=13;
}
fn();
console.log(a);
A、undefined 12 13 B、undefined undefined 12
C、undefined undefined 13 D、有程序报错

3、console.log(a);
a=12;
function fn(){
console.log(a);
a=13;
}
fn();
console.log(a); 输出的三次分别是多少
A、undefined 12 13 B、undefined undefined 12
C、undefined undefined 13 D、有程序报错

4、var foo=1;
function bar(){
if(!foo){
var foo=10;
}
console.log(foo);
}
bar(); 输出的结果是多少
A、1 B、10 C、undefined D、报错

5、var n=0;
function a(){
var n=10;
function b(){
n++;
alert(n);
}
b();
return b;
}
var c=a();
c();
alert(n);
弹出三次的结果分别是什么?
A、1 1 1 B、11 11 0 C、11 12 0 D、11 12 12

6、var a=10,b=11,c=12;
function test(a){
a=1;var b=2;c=3;
}
test(10);
alert(a); alert(b); alert©; 弹出的三个值分别是多少?
A、1 11 3 B、10 11 12 C、1 2 3 D、10 11 3

7、if(!(“a” in window)){
var a=1;
}
alert(a);
弹出的a的值是?
A、1 B、undefined C、报错 D、以上答案都不对

8、var a=4;
function b(x,y,a) {
alert(a);
arguments[2]=10;
alert(a);
}
a=b(1,2,3); alert(a); 三次弹出的结果是
A、3 3 4 B、3 10 4 C、3 10 10 D、3 10 undefined

9、var foo=‘hello’;
(function(foo){
console.log(foo);
var foo=foo||‘world’;
console.log(foo);
})(foo);
console.log(foo); 三次分别输出什么?
A、hello hello hello B、undefined world hello C、hello world world D、以上答案都不正确

10、var a=9;
function fn(){
a=0;
return function(b){ return b+a++; }
}
var f=fn()
var m=f(5);alert(m);
var n=fn()(5);alert(n);
var x=f(5);alert(x);
alert(a); 弹出的四次结果?
A、6 6 7 2 B、5 6 7 3 C、5 5 6 3 D、以上答案都不正确

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值