You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,7 @@
36
36
- Jani Hartikainen, [ES6: What are the benefits of the new features in practice?](http://codeutopia.net/blog/2015/01/06/es6-what-are-the-benefits-of-the-new-features-in-practice/)
每一个语句都会返回一个 Completion Record,表示运行结果。每个 Completion Record 有一个`[[Type]]`属性,表示运行结果的类型。
58
+
59
+
`[[Type]]`属性有五种可能的值。
60
+
61
+
- normal
62
+
- return
63
+
- throw
64
+
- break
65
+
- continue
66
+
67
+
如果`[[Type]]`的值是`normal`,就称为 normal completion,表示运行正常。其他的值,都称为 abrupt completion。其中,开发者只需要关注`[[Type]]`为`throw`的情况,即运行出错;`break`、`continue`、`return`这三个值都只出现在特定场景,可以不用考虑。
68
+
69
+
## 抽象操作的标准流程
70
+
71
+
抽象操作的运行流程,一般是下面这样。
72
+
73
+
> 1. Let resultCompletionRecord be AbstractOp().
74
+
> 1. If resultCompletionRecord is an abrupt completion, return resultCompletionRecord.
75
+
> 1. Let result be resultCompletionRecord.[[Value]].
76
+
> 1. return result.
77
+
78
+
上面的第一步是调用抽象操作`AbstractOp()`,得到`resultCompletionRecord`,这是一个 Completion Record。第二步,如果这个 Record 属于 abrupt completion,就将`resultCompletionRecord`返回给用户。如果此处没有返回,就表示运行结果正常,所得的值存放在`resultCompletionRecord.[[Value]]`属性。第三步,将这个值记为`result`。第四步,将`result`返回给用户。
0 commit comments