JavaScript-自测题11

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
console.log(a);
console.log(typeof yideng(a));
var flag = true;
if(!flag){
var a = 1;
}
if(flag){
function yideng(a){
yideng = a;
console.log('yideng1');
}
console.log(typeof yideng(a));
} else {
function yideng(a) {
yideng = a;
console.log('yideng2');
}
}
}

运行结果:

1
2
undefined
yideng is not a function

解析:

  1. a声明未赋值
  2. yideng()被限制在块级作用域内,无法检测类型