Skip to content

Commit 4305156

Browse files
committed
fix typo
1 parent f74f42a commit 4305156

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

docs/spec.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@ ECMAScript 6规格的26章之中,第1章到第3章是对文件本身的介绍
3434

3535
规格对每一种语法行为的描述,都分成两部分:先是总体的行为描述,然后是实现的算法细节。相等运算符的总体描述,只有一句话。
3636

37-
> “The comparison `x == y`, where x and y are values, produces `true` or `false`.”
37+
> “The comparison `x == y`, where `x` and `y` are values, produces `true` or `false`.”
3838
3939
上面这句话的意思是,相等运算符用于比较两个值,返回`true``false`
4040

4141
下面是算法细节。
4242

4343
> 1. ReturnIfAbrupt(x).
4444
> 1. ReturnIfAbrupt(y).
45-
> 1. If Type(x) is the same as Type(y), then
46-
> Return the result of performing Strict Equality Comparison x === y.
47-
> 1. If x is null and y is undefined, return true.
48-
> 1. If x is undefined and y is null, return true.
49-
> 1. If Type(x) is Number and Type(y) is String,
50-
> return the result of the comparison x == ToNumber(y).
51-
> 1. If Type(x) is String and Type(y) is Number,
45+
> 1. If `Type(x)` is the same as `Type(y)`, then
46+
> Return the result of performing Strict Equality Comparison `x === y`.
47+
> 1. If `x` is `null` and `y` is `undefined`, return `true`.
48+
> 1. If `x` is `undefined` and `y` is `null`, return `true`.
49+
> 1. If `Type(x)` is Number and `Type(y)` is String,
50+
> return the result of the comparison `x == ToNumber(y)`.
51+
> 1. If `Type(x)` is String and `Type(y)` is Number,
5252
> return the result of the comparison ToNumber(x) == y.
53-
> 1. If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.
54-
> 1. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
55-
> 1. If Type(x) is either String, Number, or Symbol and Type(y) is Object, then
56-
> return the result of the comparison x == ToPrimitive(y).
57-
> 1. If Type(x) is Object and Type(y) is either String, Number, or Symbol, then
58-
> return the result of the comparison ToPrimitive(x) == y.
59-
> 1. Return false.
53+
> 1. If `Type(x)` is Boolean, return the result of the comparison `ToNumber(x) == y`.
54+
> 1. If `Type(y)` is Boolean, return the result of the comparison `x == ToNumber(y)`.
55+
> 1. If `Type(x)` is either String, Number, or Symbol and `Type(y)` is Object, then
56+
> return the result of the comparison `x == ToPrimitive(y)`.
57+
> 1. If `Type(x)` is Object and `Type(y)` is either String, Number, or Symbol, then
58+
> return the result of the comparison `ToPrimitive(x) == y`.
59+
> 1. Return `false`.
6060
6161
上面这段算法,一共有12步,翻译如下。
6262

@@ -138,7 +138,7 @@ a2.map(n => 1) // [, , ,]
138138

139139
后面的算法描述是这样的。
140140

141-
> 1. Let O be ToObject(this value).
141+
> 1. Let `O` be `ToObject(this value)`.
142142
> 1. ReturnIfAbrupt(O).
143143
> 1. Let len be ToLength(Get(O, "length")).
144144
> 1. ReturnIfAbrupt(len).
@@ -147,17 +147,17 @@ a2.map(n => 1) // [, , ,]
147147
> 1. Let A be ArraySpeciesCreate(O, len).
148148
> 1. ReturnIfAbrupt(A).
149149
> 1. Let k be 0.
150-
> 1. Repeat, while k < len
151-
> a. Let Pk be ToString(k).
152-
> b. Let kPresent be HasProperty(O, Pk).
153-
> c. ReturnIfAbrupt(kPresent).
154-
> d. If kPresent is true, then
155-
> d-1. Let kValue be Get(O, Pk).
156-
> d-2. ReturnIfAbrupt(kValue).
157-
> d-3. Let mappedValue be Call(callbackfn, T, «kValue, k, O»).
158-
> d-4. ReturnIfAbrupt(mappedValue).
159-
> d-5. Let status be CreateDataPropertyOrThrow (A, Pk, mappedValue).
160-
> d-6. ReturnIfAbrupt(status).
150+
> 1. Repeat, while k < len
151+
> a. Let Pk be ToString(k).
152+
> b. Let kPresent be HasProperty(O, Pk).
153+
> c. ReturnIfAbrupt(kPresent).
154+
> d. If kPresent is true, then
155+
> d-1. Let kValue be Get(O, Pk).
156+
> d-2. ReturnIfAbrupt(kValue).
157+
> d-3. Let mappedValue be Call(callbackfn, T, «kValue, k, O»).
158+
> d-4. ReturnIfAbrupt(mappedValue).
159+
> d-5. Let status be CreateDataPropertyOrThrow (A, Pk, mappedValue).
160+
> d-6. ReturnIfAbrupt(status).
161161
> e. Increase k by 1.
162162
> 1. Return A.
163163
@@ -172,17 +172,17 @@ a2.map(n => 1) // [, , ,]
172172
> 1. 生成一个新的数组`A`,跟当前数组的`length`属性保持一致
173173
> 1. 如果报错就返回
174174
> 1. 设定`k`等于0
175-
> 1. 只要`k`小于当前数组的`length`属性,就重复下面步骤
176-
> a. 设定`Pk`等于`ToString(k)`,即将`K`转为字符串
177-
> b. 设定`kPresent`等于`HasProperty(O, Pk)`,即求当前数组有没有指定属性
178-
> c. 如果报错就返回
179-
> d. 如果`kPresent`等于`true`,则进行下面步骤
180-
> d-1. 设定`kValue`等于`Get(O, Pk)`,取出当前数组的指定属性
181-
> d-2. 如果报错就返回
182-
> d-3. 设定`mappedValue`等于`Call(callbackfn, T, «kValue, k, O»)`,即执行回调函数
183-
> d-4. 如果报错就返回
184-
> d-5. 设定`status`等于`CreateDataPropertyOrThrow (A, Pk, mappedValue)`,即将回调函数的值放入`A`数组的指定位置
185-
> d-6. 如果报错就返回
175+
> 1. 只要`k`小于当前数组的`length`属性,就重复下面步骤
176+
> a. 设定`Pk`等于`ToString(k)`,即将`K`转为字符串
177+
> b. 设定`kPresent`等于`HasProperty(O, Pk)`,即求当前数组有没有指定属性
178+
> c. 如果报错就返回
179+
> d. 如果`kPresent`等于`true`,则进行下面步骤
180+
> d-1. 设定`kValue`等于`Get(O, Pk)`,取出当前数组的指定属性
181+
> d-2. 如果报错就返回
182+
> d-3. 设定`mappedValue`等于`Call(callbackfn, T, «kValue, k, O»)`,即执行回调函数
183+
> d-4. 如果报错就返回
184+
> d-5. 设定`status`等于`CreateDataPropertyOrThrow (A, Pk, mappedValue)`,即将回调函数的值放入`A`数组的指定位置
185+
> d-6. 如果报错就返回
186186
> e. `k`增加1
187187
> 1. 返回`A`
188188

0 commit comments

Comments
 (0)