@@ -1027,16 +1027,16 @@ typeof sayHi()
1027
1027
1028
1028
#### 答案: B
1029
1029
1030
- The ` sayHi ` function returns the returned value of the immediately invoked function (IIFE). This function returned ` 0 ` , which is type ` " number" ` .
1030
+ ` sayHi ` 方法返回的是立即执行函数 (IIFE)的返回值.此立即执行函数的返回值是 ` 0 ` , 类型是 ` number `
1031
1031
1032
- FYI: there are only 7 built-in types: ` null ` , ` undefined ` , ` boolean ` , ` number ` , ` string ` , ` object ` , and ` symbol ` . ` " function" ` is not a type, since functions are objects, it's of type ` " object" ` .
1032
+ 参考:只有7种内置类型: ` null ` , ` undefined ` , ` boolean ` , ` number ` , ` string ` , ` object ` 和 ` symbol ` 。 `` function `` 不是一种类型,函数是对象,它的类型是 `` object `` 。
1033
1033
1034
1034
</p >
1035
1035
</details >
1036
1036
1037
1037
---
1038
1038
1039
- ###### 35. Which of these values are falsy?
1039
+ ###### 35. 下面哪些值是 falsy?
1040
1040
1041
1041
``` javascript
1042
1042
0
@@ -1057,7 +1057,9 @@ undefined
1057
1057
1058
1058
#### 答案: A
1059
1059
1060
- There are only six falsy values:
1060
+ 只有 6 种 [ falsy] ( https://developer.mozilla.org/zh-CN/docs/Glossary/Falsy ) 值:
1061
+
1062
+
1061
1063
1062
1064
- ` undefined `
1063
1065
- ` null `
@@ -1066,7 +1068,7 @@ There are only six falsy values:
1066
1068
- ` '' ` (empty string)
1067
1069
- ` false `
1068
1070
1069
- Function constructors, like ` new Number ` and ` new Boolean ` are truthy.
1071
+ ` Function ` 构造函数, 比如 ` new Number ` 和 ` new Boolean ` ,是 [ truthy] ( https://developer.mozilla.org/zh-CN/docs/Glossary/Truthy ) 。
1070
1072
1071
1073
</p >
1072
1074
</details >
@@ -1089,8 +1091,8 @@ console.log(typeof typeof 1)
1089
1091
1090
1092
#### 答案: B
1091
1093
1092
- ` typeof 1 ` returns ` "number" ` .
1093
- ` typeof "number" ` returns ` "string" `
1094
+ ` typeof 1 ` 返回 ` "number" ` 。
1095
+ ` typeof "number" ` 返回 ` "string" ` 。
1094
1096
1095
1097
</p >
1096
1098
</details >
@@ -1115,11 +1117,11 @@ console.log(numbers)
1115
1117
1116
1118
#### 答案: C
1117
1119
1118
- When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of ` undefined ` , but you will see something like:
1120
+ 当你为数组设置超过数组长度的值的时候, JavaScript 会创建名为 "empty slots" 的东西。它们的值实际上是 ` undefined ` 。你会看到以下场景:
1119
1121
1120
1122
` [1, 2, 3, 7 x empty, 11] `
1121
1123
1122
- depending on where you run it (it's different for every browser, node, etc.)
1124
+ 这取决于你的运行环境(每个浏览器,以及 node 环境,都有可能不同)
1123
1125
1124
1126
</p >
1125
1127
</details >
@@ -1152,32 +1154,32 @@ depending on where you run it (it's different for every browser, node, etc.)
1152
1154
1153
1155
#### 答案: A
1154
1156
1155
- The ` catch ` block receives the argument ` x ` . This is not the same ` x ` as the variable when we pass arguments. This variable ` x ` is block-scoped.
1157
+ ` catch ` 代码块接收参数 ` x ` 。当我们传递参数时,这与之前定义的变量 ` x ` 不同 。这个 ` x ` 是属于 ` catch ` 块级作用域的。
1156
1158
1157
- Later, we set this block-scoped variable equal to ` 1 ` , and set the value of the variable ` y ` . Now, we log the block-scoped variable ` x ` , which is equal to ` 1 ` .
1159
+ 然后,我们将块级作用域中的变量赋值为 ` 1 ` ,同时也设置了变量 ` y ` 的值。现在,我们打印块级作用域中的变量 ` x ` ,值为 ` 1 ` 。
1158
1160
1159
- Outside of the ` catch ` block, ` x ` is still ` undefined ` , and ` y ` is ` 2 ` . When we want to ` console.log(x) ` outside of the ` catch ` block, it returns ` undefined ` , and ` y ` returns ` 2 ` .
1161
+ ` catch ` 块之外的变量 ` x ` 的值仍为 ` undefined ` , ` y ` 的值为 ` 2 ` 。当我们在 ` catch ` 块之外执行 ` console.log(x) ` 时,返回 ` undefined ` , ` y ` 返回 ` 2 ` 。
1160
1162
1161
1163
</p >
1162
1164
</details >
1163
1165
1164
1166
---
1165
1167
1166
- ###### 39. Everything in JavaScript is either a...
1168
+ ###### 39. JavaScript 中的一切都是?
1167
1169
1168
1170
- A: primitive or object
1169
1171
- B: function or object
1170
1172
- C: trick question! only objects
1171
1173
- D: number or object
1172
-
1174
+ -
1173
1175
<details ><summary ><b >答案</b ></summary >
1174
1176
<p >
1175
1177
1176
1178
#### 答案: A
1177
1179
1178
- JavaScript only has primitive types and objects.
1180
+ JavaScript 只有原始类型和对象。
1179
1181
1180
- Primitive types are ` boolean ` , ` null ` , ` undefined ` , ` bigint ` , ` number ` , ` string ` , and ` symbol ` .
1182
+ 原始类型包括 ` boolean ` , ` null ` , ` undefined ` , ` bigint ` , ` number ` , ` string ` , ` symbol ` 。
1181
1183
1182
1184
</p >
1183
1185
</details >
@@ -1205,9 +1207,8 @@ Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`
1205
1207
1206
1208
#### 答案: C
1207
1209
1208
- ` [1, 2] ` is our initial value. This is the value we start with, and the value of the very first ` acc ` . During the first round, ` acc ` is ` [1,2] ` , and ` cur ` is ` [0, 1] ` . We concatenate them, which results in ` [1, 2, 0, 1] ` .
1209
-
1210
- Then, ` [1, 2, 0, 1] ` is ` acc ` and ` [2, 3] ` is ` cur ` . We concatenate them, and get ` [1, 2, 0, 1, 2, 3] `
1210
+ ` [1, 2] ` 是初始值。初始值将会作为首次调用时第一个参数 ` acc ` 的值。在第一次执行时, ` acc ` 的值是 ` [1, 2] ` , ` cur ` 的值是 ` [0, 1] ` 。合并它们,结果为 ` [1, 2, 0, 1] ` 。
1211
+ 第二次执行, ` acc ` 的值是 ` [1, 2, 0, 1] ` , ` cur ` 的值是 ` [2, 3] ` 。合并它们,最终结果为 ` [1, 2, 0, 1, 2, 3] `
1211
1212
1212
1213
</p >
1213
1214
</details >
@@ -1232,18 +1233,18 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge
1232
1233
1233
1234
#### 答案: B
1234
1235
1235
- ` null ` is falsy. ` !null ` returns ` true ` . ` !true ` returns ` false ` .
1236
+ ` null ` 是 [ falsy] ( https://developer.mozilla.org/zh-CN/docs/Glossary/Falsy ) 。 ` !null ` 的值是 ` true ` 。 ` !true ` 的值是 ` false ` 。
1236
1237
1237
- ` "" ` is falsy. ` !"" ` returns ` true ` . ` !true ` returns ` false ` .
1238
+ ` "" ` 是 [ falsy] ( https://developer.mozilla.org/zh-CN/docs/Glossary/Falsy ) 。 ` !"" ` 的值是 ` true ` 。 ` !true ` 的值是 ` false ` 。
1238
1239
1239
- ` 1 ` is truthy. ` !1 ` returns ` false ` . ` !false ` returns ` true ` .
1240
+ ` 1 ` 是 [ truthy] ( https://developer.mozilla.org/zh-CN/docs/Glossary/Truthy ) 。 ` !1 ` 的值是 ` false ` 。 ` !false ` 的值是 ` true ` 。
1240
1241
1241
1242
</p >
1242
1243
</details >
1243
1244
1244
1245
---
1245
1246
1246
- ###### 42. What does the ` setInterval ` method return?
1247
+ ###### 42. ` setInterval ` 方法的返回值是什么?
1247
1248
1248
1249
``` javascript
1249
1250
setInterval (() => console .log (' Hi' ), 1000 )
@@ -1259,14 +1260,14 @@ setInterval(() => console.log('Hi'), 1000)
1259
1260
1260
1261
#### 答案: A
1261
1262
1262
- It returns a unique id. This id can be used to clear that interval with the ` clearInterval() ` function.
1263
+ ` setInterval ` 返回一个唯一的 id。此 id 可被用于 ` clearInterval ` 函数来取消定时。
1263
1264
1264
1265
</p >
1265
1266
</details >
1266
1267
1267
1268
---
1268
1269
1269
- ###### 43. What does this return?
1270
+ ###### 43. 输出是什么?
1270
1271
1271
1272
``` javascript
1272
1273
;[... ' Lydia' ]
@@ -1282,7 +1283,7 @@ It returns a unique id. This id can be used to clear that interval with the `cle
1282
1283
1283
1284
#### 答案: A
1284
1285
1285
- A string is an iterable. The spread operator maps every character of an iterable to one element.
1286
+ string 类型是可迭代的。扩展运算符将迭代的每个字符映射成一个元素。
1286
1287
1287
1288
</p >
1288
1289
</details >
0 commit comments