1. 下面代码的输出是什么 ?
class Chameleon {
static colorChange(newColor) {
this.newColor = newColor;
}
constructor({ newColor = "green" } = {}) {
this.newColor = newColor;
}
}
const freddie = new Chameleon({ newColor: "purple" });
freddie.colorChange("orange");
* A: orange
* B: purple
* C: green
* D: TypeError
2. 下面代码的输出是什么 ?
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
const member = new Person("Lydia", "Hallie");
Person.getFullName = () => this.firstName + this.lastName;
console.log(member.getFullName());
* A: TypeError
* B: SyntaxError
* C: Lydia Hallie
* D: undefined undefined
3. 事件传播的三个阶段是什么??
* A: 目标 > 捕获 > 冒泡
* B: 冒泡 > 目标 > 捕获
* C: 目标 > 冒泡 > 捕获
* D: 捕获 > 目标 > 冒泡
4. 所有对象都有原型.
* A: 对
* B: 错误
5. 下面代码的输出是什么 ?
let number = 0;
console.log(number++);
console.log(++number);
console.log(number);
* A: 1 1 2
* B: 1 2 2
* C: 0 2 2
* D: 0 1 2
6. 下面代码的输出是什么 ?
function checkAge(data) {
if (data === { age: 18 }) {
console.log("You are an adult!");
} else if (data == { age: 18 }) {
console.log("You are still an adult.");
} else {
console.log(`Hmm.. You don't have an age I guess`);
}
}
checkAge({ age: 18 });
* A: You are an adult!
* B: You are still an adult.
* C: Hmm..You don't have an age I guess
7. 下面代码的输出是什么 ?
function getAge(...args) {
console.log(typeof args);
}
getAge(21);
* A: "number"
* B: "array"
* C: "object"
* D: "NaN"
8. 下面代码的输出是什么 ?const sum = eval("10*10+5");
* A: 105
* B: "105"
* C: TypeError
* D: "10*10+5"
9. cool_secret可以访问多长时间 ? sessionStorage.setItem("cool_secret", 123);
* A:永远,数据不会丢失。
* B:用户关闭选项卡时。
* C:当用户关闭整个浏览器时,不仅是选项卡。
* D:用户关闭计算机时。
10. 下面代码的输出是什么 ?
const obj = { 1: "a", 2: "b", 3: "c" };
const set = new Set([1, 2, 3, 4, 5]);
obj.hasOwnProperty("1");
obj.hasOwnProperty(1);
set.has("1");
set.has(1);
* A: false true false true
* B: false true true true
* C: true true false true
* D: true true true true
11. JavaScript全局执行上下文为你创建了两个东西: 全局对象和this关键字.
* A: 对
* B: 错误
* C: 视情况而定
12. 下面代码的输出是什么 ?
for (let i = 1; i < 5; i++) {
if (i === 3) continue;
console.log(i);
}
* A: 1 2
* B: 1 2 3
* C: 1 2 4
* D: 1 3 4
13. 下面代码的输出是什么 ?
String.prototype.giveLydiaPizza = () => {
return "Just give Lydia pizza already!";
};
const name = "Lydia"; name.giveLydiaPizza();
* A: "Just give Lydia pizza already!"
* B: TypeError: not a function* C: SyntaxError
* D: undefined
14. 单击按钮时event.target是什么 ?
<div οnclick="console.log('first div')">
<div οnclick="console.log('second div')">
<button οnclick="console.log('button')"> Click! </button>
</div>
</div>
* A : div外部
* B: div内部
* C: button
* D: 所有嵌套元素的数组.
15. 下面代码的输出是什么 ?
const person = { name: "Lydia" };
function sayHi(age) {
console.log(`${this.name} is ${age}`);
}
sayHi.call(person, 21);
sayHi.bind(person, 21);
* A: undefined is 21 Lydia is 21
* B: function function* C: Lydia is 21 Lydia is 21
* D: Lydia is 21 function
16. 下面代码的输出是什么 ?
function sayHi() {
return (() => 0)();
}
typeof sayHi();
* A: "object"
* B: "number"
* C: "function"
* D: "undefined"
17. 下面代码的输出是什么 ? console.log(typeof typeof 1);
* A: "number"
* B: "string"
* C: "object"
* D: "undefined"
18. 下面代码的输出是什么 ?
const numbers = [1, 2, 3];
numbers[10] = 11;
console.log(numbers);
* A: [1, 2, 3, 7 x null, 11]
* B: [1, 2, 3, 11]
* C: [1, 2, 3, 7 x empty, 11]
* D: SyntaxError
19. JavaScript中的所有内容都是…
* A:原始或对象
* B:函数或对象
* C:技巧问题!只有对象
* D:数字或对象
20. 下面代码的输出是什么 ?
[[0, 1], [2, 3]].reduce(
(acc, cur) => {
return acc.concat(cur);
}, [1, 2]);
* A: [0, 1, 2, 3, 1, 2]
* B: [6, 1, 2]
* C: [1, 2, 0, 1, 2, 3]
* D: [1, 2, 6]
21. `setInterval`方法的返回值什么 ? setInterval(() => console.log("Hi"), 1000);
* A:一个唯一的id
* B:指定的毫秒数
* C:传递的函数
* D:undefined
22. What does this return? [..."Lydia"];
* A: ["L", "y", "d", "i", "a"]
* B: ["Lydia"]
* C: [[], "Lydia"]
* D: [["L", "y", "d", "i", "a"]]
23. 下面代码的返回值是什么 ?
const firstPromise = newPromise((res, rej) => {
setTimeout(res, 500, "one");
});
const secondPromise = newPromise((res, rej) => {
setTimeout(res, 100, "two");
});
Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
* A: "one"
* B: "two"
* C: "two""one"
* D: "one""two"
24. 下面代码的输出是什么 ?
const person = {
name: "Lydia",
age: 21
};
for (const item in person) {
console.log(item);
}
* A: { name: "Lydia" }, { age: 21 }
* B: "name", "age"
* C: "Lydia", 21
* D: ["name", "Lydia"], ["age", 21]
25. 下面代码的输出是什么 ?
console.log(3 + 4 + "5");
* A: "345"
* B: "75"
* C: 12
* D: "12"
26. num的值是什么 ?
const num = parseInt("7*6", 10);
* A: 42
* B: "42"
* C: 7
* D: NaN
27.下面代码输出什么 ?
const one = (false || {} || null)
const two = (null || false || "")
const three = ([] || 0 || true)
console.log(one, two, three)
* A: false null[]
* B: null "" true
* C: { } ""[]
* D: null null true
28. 下面代码输出什么 ?
const output = `${[] && 'Im'}possible!
You should${'' && `n't`} see a therapist after so much JavaScript lol`
* A: possible!Youshould see a therapist after so muchJavaScriptlol
* B: Impossible!Youshould see a therapist after so muchJavaScriptlol
* C: possible!Youshouldn't see a therapist after so much JavaScript lol
* D: Impossible!Youshouldn't see a therapist after so much JavaScript lol
29. 下面代码输出什么 ?
const name = "Lydia"
console.log(name())
* A: SyntaxError
* B: ReferenceError
* C: TypeError
* D: undefined
30. 下面代码输出什么 ?
const getList = ([x, ...y]) => [x, y]
const getUser = user => { name: user.name, age: user.age }
const list = [1, 2, 3, 4]
const user = { name: "Lydia", age: 21 }
console.log(getList(list))
console.log(getUser(user))
* A: [1, [2, 3, 4]] and undefined
* B: [1, [2, 3, 4]] and { name: "Lydia", age: 21 }
* C: [1, 2, 3, 4] and { name: "Lydia", age: 21 }
* D: Error and { name: "Lydia", age: 21 }
31. 下面代码输出什么 ?
const info = {
[Symbol('a')]: 'b'
}
console.log(info)
console.log(Object.keys(info))
* A: { Symbol('a'): 'b' } and["{Symbol('a')"]
* B: { } and[]
* C: { a: "b" } and["a"]
* D: { Symbol('a'): 'b' } and[]
32. 下面代码输出什么 ?
classPerson {
constructor() {
this.name = "Lydia"
}
}
Person = classAnotherPerson {
constructor() {
this.name = "Sarah"
}
}
const member = newPerson()
console.log(member.name)
* A: "Lydia"
* B: "Sarah"
* C: Error:cannot redeclarePerson
* D: SyntaxError
33. 下面代码输出什么 ?
function getItems(fruitList, ...args, favoriteFruit) {
return [...fruitList, ...args, favoriteFruit]
}
getItems(["banana", "apple"], "pear", "orange")
* A: ["banana", "apple", "pear", "orange"]
* B: [["banana", "apple"], "pear", "orange"]
* C: ["banana", "apple", ["pear"], "orange"]
* D: SyntaxError
34. 下面代码输出什么 ?
const person = {
name: "Lydia",
age: 21
}
for (const [x, y] of Object.entries(person)) {
console.log(x, y)
}
* A: name Lydia and age 21
* B: ["name", "Lydia"] and["age", 21]
* C: ["name", "age"] and undefined
* D: Error
35. 下面代码输出什么 ?
let newList = [1, 2, 3].push(4)
console.log(newList.push(5))
* A: [1, 2, 3, 4, 5]
* B: [1, 2, 3, 5]
* C: [1, 2, 3, 4]
* D: Error
36. 下面代码输出什么 ?
classPerson {
constructor(name) {
this.name = name
}
}
const member = newPerson("John")
console.log(typeof member)
* A: "class"
* B: "function"
* C: "object"
* D: "string"
37. 下面代码输出什么 ?
console.log("I want pizza"[0])
* A : """
* B: "I"
* C: SyntaxError
* D: undefined
38. 哪个选项是将 hasName设置为 true的方法,前提是不能将 true作为参数传递 ?
function getName(name) {
const hasName = //
}
* A : !!name
* B: name
* C: newBoolean(name)
* D: name.length
39. 什么样的信息将被打印 ?
fetch('https://www.website.com/api/user/1')
.then(res => res.json())
.then(res => console.log(res))
* A : fetch方法的结果
* B: 第二次调用 fetch方法的结果
* C: 前一个.then()中回调方法返回的结果
* D: 总是 undefined
40. 下面代码输出什么 ?
function checkAge(age) {
if (age < 18) {
const message = "Sorry, you're too young."
} else {
const message = "Yay! You're old enough!"
}
return message
}
console.log(checkAge(21))
* A: "Sorry, you're too young."
* B: "Yay! You're old enough!"
* C: ReferenceError
* D: undefined
41. 下面代码输出什么 ?
function sayHi(name) {
return `Hi there, ${name}`
}
console.log(sayHi())
* A: Hithere,
* B: Hithere, undefined
* C: Hithere, null
* D: ReferenceError
42. 下面代码输出什么 ?
const list = [1 + 2, 1 * 2, 1 / 2]
console.log(list)
* A: ["1 + 2", "1 * 2", "1 / 2"]
* B: ["12", 2, 0.5]
* C: [3, 2, 0.5]
* D: [1, 1, 1]
43. 以下是个纯函数么 ?
function sum(a, b) {
return a + b;
}
* A : Yes
* B: No
44. 下面代码输出什么 ?
const { name: myName } = { name: "Lydia" };
console.log(name);
* A: "Lydia"
* B: "myName"
* C: undefined
* D: ReferenceError
45. 下面代码输出什么 ?
const box = { x: 10, y: 20 };
Object.freeze(box);
const shape = box;
shape.x = 100;
console.log(shape)
* A: { x: 100, y: 20 }
* B: { x: 10, y: 20 }
* C: { x: 100 }
* D: ReferenceError
46. 下面代码的输出是什么 ?
functionCar(){
this.make = "Lamborghini";
return { make: "Maserati" };
}
const myCar = newCar();
console.log(myCar.make);
* A: "Lamborghini"
* B: "Maserati"
* C: ReferenceError
* D: TypeError
47. 下面代码的输出是什么 ?
constset = newSet([1, 1, 2, 3, 4]);
console.log(set);
* A: [1, 1, 2, 3, 4]
* B: [1, 2, 3, 4]
* C: { 1, 1, 2, 3, 4 }
* D: { 1, 2, 3, 4 }
48. 下面代码的输出是什么 ?
let counter = 10;
exportdefault counter;
import myCounter from "./counter";
myCounter += 1;
console.log(myCounter);
* A: 10
* B: 11
* C: Error
* D: NaN
49. 下面代码的输出是什么 ?
const name = "Lydia";
age = 21;
console.log(delete name);
console.log(delete age);
* A: false, true
* B: "Lydia", 21
* C: true, true
* D: undefined, undefined
50. 下面代码的输出是什么 ?
const numbers = [1, 2, 3, 4, 5];
const [y] = numbers;
console.log(y);
* A: [[1, 2, 3, 4, 5]]
* B: [1, 2, 3, 4, 5]
* C: 1
* D: [1]
51. 下面代码输出什么?
const myLifeSummedUp = ["☕", "?", "?", "?"]
for (let item in myLifeSummedUp) {
console.log(item)
}
for (let item of myLifeSummedUp) {
console.log(item)
}
* A: 0 1 2 3 and "☕" "?" "?" "?"
* B: "☕" "?" "?" "?" and "☕" "?" "?" "?"
* C: "☕" "?" "?" "?" and 0 1 2 3
* D: 0 1 2 3 and {0:"☕",1:"?",2:"?",3:"?"}
52. 下面代码的输出是什么 ?
const user = { name: "Lydia", age: 21 };
const admin = { admin: true, ...user };
console.log(admin);
* A: { admin: true, user: { name: "Lydia", age: 21 } }
* B: { admin: true, name: "Lydia", age: 21 }
* C: { admin: true, user: ["Lydia", 21] }
* D: { admin: true }
54.function getItems(fruitList, favoriteFruit, ...args) {
return [...fruitList, ...args, favoriteFruit]
}
getItems(["banana", "apple"], "pear", "orange")
上述例子是有效的,将会返回数组:['banana', 'apple', 'orange', 'pear']下面代码输出什么 ?
function nums(a, b) {
if (a > b) {
console.log('a is bigger')
} else {
console.log('b is bigger')
return a + b
}
}
console.log(nums(4, 2))
console.log(nums(1, 2))
* A: aisbigger, 6 and bisbigger, 3
* B: aisbigger, undefined and bisbigger, undefined
* C: undefined and undefined
* D: SyntaxError
53. 下面代码的输出是什么 ?
let num = 10;
const increaseNumber = () => num++;
const increasePassedNumber = number => number++;
const num1 = increaseNumber();
const num2 = increasePassedNumber(num1);
console.log(num1);
console.log(num2);
* A: 10, 10
* B: 10, 11
* C: 11, 11
* D: 11, 12
55. 下面代码输出什么 ?
console.log('running index.js');
import { sum } from './sum.js';
console.log(sum(1, 2));
console.log('running sum.js');
exportconst sum = (a, b) => a + b;
* A: running index.js, running sum.js, 3
* B: running sum.js, running index.js, 3
* C: running sum.js, 3, running index.js
* D: running index.js, undefined, running sum.js
56. 下面代码输出什么 ?
console.log(Number(2) === Number(2))
console.log(Boolean(false) === Boolean(false))
console.log(Symbol('foo') === Symbol('foo'))
* A: true, true, false
* B: false, true, false
* C: true, false, true
* D: true, true, true
57. 下面代码输出什么 ?
const name = "Lydia Hallie"
console.log(name.padStart(13))
console.log(name.padStart(2))
* A: "Lydia Hallie", "Lydia Hallie"
* B: " Lydia Hallie", " Lydia Hallie"("[13x whitespace]Lydia Hallie", "[2x whitespace]Lydia Hallie")
* C: " Lydia Hallie", "Lydia Hallie"("[1x whitespace]Lydia Hallie", "Lydia Hallie")
* D: "Lydia Hallie", "Lyd"
58. 下面代码输出什么 ?
console.log("?" + "?");
* A: "??"
* B: 257548
* C: A string containing their code points
* D: Error
59. 下面代码输出什么 ?
console.log(String.raw`Hello\nworld`);
* A: Helloworld!
* B: Hello world
* C: Hello\nworld
* D: Hello\n world
60.下面代码输出什么 ?
async function getData() {
return await Promise.resolve("I made it!");
}
const data = getData();
console.log(data);
* A: "I made it!"
* B: Promise{
<resolved>:"I made it!"}
* C: Promise{<pending>}
* D: undefined