Skip to content

Commit df9eb3d

Browse files
committed
question 26-30
1 parent fd3093b commit df9eb3d

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

README-zh_CN.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ console.log(greetign)
298298

299299
---
300300

301-
###### 10. What happens when we do this?
301+
###### 10. 当我们这么做时,会发生什么?
302302

303303
```javascript
304304
function bark() {
@@ -433,7 +433,7 @@ console.log(sarah)
433433

434434
#### 答案: B
435435

436-
除了**基对象**(base object),所有对象都有原型。基对象可以访问一些方法和属性,比如 `.tostring`。这就是为什么你可以使用内置的 JavaScript 方法!所有这些方法在原型上都是可用的。虽然 JavaScript 不能直接在对象上找到这些方法,但 JavaScript 会沿着原型链找到它们,以便于你使用。
436+
除了**基本对象**(base object),所有对象都有原型。基本对象可以访问一些方法和属性,比如 `.tostring`。这就是为什么你可以使用内置的 JavaScript 方法!所有这些方法在原型上都是可用的。虽然 JavaScript 不能直接在对象上找到这些方法,但 JavaScript 会沿着原型链找到它们,以便于你使用。
437437

438438
</p>
439439
</details>
@@ -759,7 +759,7 @@ If you have two keys with the same name, the key will be replaced. It will still
759759

760760
---
761761

762-
###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
762+
###### 26. JavaScript 全局执行上下文为你做了两件事:全局对象和 this 关键字。
763763

764764
- A: true
765765
- B: false
@@ -770,7 +770,7 @@ If you have two keys with the same name, the key will be replaced. It will still
770770

771771
#### 答案: A
772772

773-
The base execution context is the global execution context: it's what's accessible everywhere in your code.
773+
基本执行上下文是全局执行上下文:它是代码中随处可访问的内容。
774774

775775
</p>
776776
</details>
@@ -796,7 +796,7 @@ for (let i = 1; i < 5; i++) {
796796

797797
#### 答案: C
798798

799-
The `continue` statement skips an iteration if a certain condition returns `true`.
799+
如果某个条件返回 `true`,则 `continue` 语句跳过本次迭代。
800800

801801
</p>
802802
</details>
@@ -825,7 +825,7 @@ name.giveLydiaPizza()
825825

826826
#### 答案: A
827827

828-
`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
828+
`String` 是内置的构造函数,我们可以向它添加属性。我只是在它的原型中添加了一个方法。基本类型字符串被自动转换为字符串对象,由字符串原型函数生成。因此,所有 string(string 对象)都可以访问该方法!
829829

830830
</p>
831831
</details>
@@ -855,11 +855,11 @@ console.log(a[b])
855855

856856
#### 答案: B
857857

858-
Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
858+
对象的键被自动转换为字符串。我们试图将一个对象 `b` 设置为对象 `a` 的键,且相应的值为 `123`
859859

860-
However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
860+
然而,当字符串化一个对象时,它会变成 `"[Object object]"`。因此这里说的是,`a["Object object"] = 123`。然后,我们再一次做了同样的事情,`c` 是另外一个对象,这里也有隐式字符串化,于是,`a["Object object"] = 456`
861861

862-
Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
862+
然后,我们打印 `a[b]`,也就是 `a["Object object"]`。之前刚设置为 `456`,因此返回的是 `456`
863863

864864
</p>
865865
</details>
@@ -888,38 +888,38 @@ baz()
888888

889889
#### 答案: B
890890

891-
We have a `setTimeout` function and invoked it first. Yet, it was logged last.
891+
我们有一个 `setTimeout` 函数,并首先调用它。然而,它是最后打印的。
892892

893-
This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
893+
这是因为在浏览器中,我们不仅有运行时引擎,还有一个叫做 `WebAPI` 的东西。`WebAPI` 提供了 `setTimeout` 函数,也包含其他的,例如 DOM
894894

895-
After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
895+
_callback_ 推送到 WebAPI 后,`setTimeout` 函数本身(但不是回调!)将从栈中弹出。
896896

897897
<img src="https://i.imgur.com/X5wsHOg.png" width="200">
898898

899-
Now, `foo` gets invoked, and `"First"` is being logged.
899+
现在,`foo` 被调用,打印 `"First"`
900900

901901
<img src="https://i.imgur.com/Pvc0dGq.png" width="200">
902902

903-
`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
903+
`foo` 从栈中弹出,`baz` 被调用. 打印 `"Third"`
904904

905905
<img src="https://i.imgur.com/WhA2bCP.png" width="200">
906906

907-
The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
907+
WebAPI 不能随时向栈内添加内容。相反,它将回调函数推到名为 _queue_ 的地方。
908908

909909
<img src="https://i.imgur.com/NSnDZmU.png" width="200">
910910

911-
This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
911+
这就是事件循环开始工作的地方。一个**事件循环**查看栈和任务队列。如果栈是空的,它接受队列上的第一个元素并将其推入栈。
912912

913913
<img src="https://i.imgur.com/uyiScAI.png" width="200">
914914

915-
`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
915+
`bar` 被调用,打印 `"Second"`,然后它被栈弹出。
916916

917917
</p>
918918
</details>
919919

920920
---
921921

922-
###### 31. What is the event.target when clicking the button?
922+
###### 31. 当点击按钮时,event.target是什么?
923923

924924
```html
925925
<div onclick="console.log('first div')">

0 commit comments

Comments
 (0)