1. 下面代码的输出是什么? +true;!"Lydia";
* A: 1 and false
* B: false and NaN
* C: false and false
2. 下面代码的输出是什么?function sayHi() { console.log(name); console.log(age);
var name = "Lydia"; let age = 21;}sayHi();
* A: Lydia 和 undefined
* B: Lydia 和 ReferenceError
* C: ReferenceError 和 21
* D: undefined 和 ReferenceError
3. 下面代码的输出是什么?
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1);
}
for (let i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1);
}
* A: 0 1 2 and 0 1 2
* B: 0 1 2 and 3 3 3
* C: 3 3 3 and 0 1 2
4. 下面代码的输出是什么?
const shape = {
radius: 10,
diameter() {
return this.radius * 2;
},
perimeter: () => 2 * Math.PI * this.radius
};
shape.diameter();
shape.perimeter();
* A: 20 and 62.83185307179586
* B: 20 and NaN
* C: 20 and 63
* D: NaN and 63