以下代码执行后,console 的输出是?
1
2
3
4
5
6
7
let x = 10;
let foo = () => {
console.log(x);
let x = 20;
x++;
}
foo();
因为let是块级作用域,再FOO中根本就没有x这个变量,所以输出ReferenceError
执行以下程序,当用户在prompt输入框中输入0时,输出结果为()
var num = prompt('请输入分母:')
try{ console.log('a');
value = 0 / num;
console.log('b');
}
catch(e){
console.log('c');
}
finally{
console.log('d');
}
在js中,任何得以0的数都不会报错,会返回NaN,程序正常运行
分析下面代码块,输出( )行########。
1
2
3
4
5
6
7
var i =
0
;
while
( i <
40
){
if
( i <
30
)
continue
;
Document.write(‘########’);
i++;
}
continue直接跳出循环,永远也不会执行到i++,所以输出0行
原生具备 Iterator 接口的数据结构如下:
- Array
- Map
- Set
- String
- TypedArray
- 函数的 arguments 对象
- NodeList 对象
这些是js中内置可以迭代的所有对象。