Skip to content

Commit 86a012f

Browse files
author
wuzhiyu5
committed
调整描述以符合伪代码中展示内容
1 parent 6fc5573 commit 86a012f

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

docs/spec.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,18 @@ ES6 规格将这个标准流程,使用简写的方式表达。
124124
> 1. ReturnIfAbrupt(x).
125125
> 1. ReturnIfAbrupt(y).
126126
> 1. If `Type(x)` is the same as `Type(y)`, then
127-
> 1. Return the result of performing Strict Equality Comparison `x === y`.
127+
> 1. Return the result of performing Strict Equality Comparison `x === y`.
128128
> 1. If `x` is `null` and `y` is `undefined`, return `true`.
129129
> 1. If `x` is `undefined` and `y` is `null`, return `true`.
130-
> 1. If `Type(x)` is Number and `Type(y)` is String,</br>
130+
> 1. If `Type(x)` is Number and `Type(y)` is String,
131131
> return the result of the comparison `x == ToNumber(y)`.
132-
> 1. If `Type(x)` is String and `Type(y)` is Number,</br>
132+
> 1. If `Type(x)` is String and `Type(y)` is Number,
133133
> return the result of the comparison `ToNumber(x) == y`.
134134
> 1. If `Type(x)` is Boolean, return the result of the comparison `ToNumber(x) == y`.
135135
> 1. If `Type(y)` is Boolean, return the result of the comparison `x == ToNumber(y)`.
136-
> 1. If `Type(x)` is either String, Number, or Symbol and `Type(y)` is Object, then</br>
136+
> 1. If `Type(x)` is either String, Number, or Symbol and `Type(y)` is Object, then
137137
> return the result of the comparison `x == ToPrimitive(y)`.
138-
> 1. If `Type(x)` is Object and `Type(y)` is either String, Number, or Symbol, then</br>
138+
> 1. If `Type(x)` is Object and `Type(y)` is either String, Number, or Symbol, then
139139
> return the result of the comparison `ToPrimitive(x) == y`.
140140
> 1. Return `false`.
141141
@@ -229,17 +229,17 @@ a2.map(n => 1) // [, , ,]
229229
> 1. `ReturnIfAbrupt(A)`.
230230
> 1. Let `k` be 0.
231231
> 1. Repeat, while `k` < `len`
232-
> 1. Let `Pk` be `ToString(k)`.
233-
> 1. Let `kPresent` be `HasProperty(O, Pk)`.
234-
> 1. `ReturnIfAbrupt(kPresent)`.
235-
> 1. If `kPresent` is `true`, then
236-
> 1. Let `kValue` be `Get(O, Pk)`.
237-
> 1. `ReturnIfAbrupt(kValue)`.
238-
> 1. Let `mappedValue` be `Call(callbackfn, T, «kValue, k, O»)`.
239-
> 1. `ReturnIfAbrupt(mappedValue)`.
240-
> 1. Let `status` be `CreateDataPropertyOrThrow (A, Pk, mappedValue)`.
241-
> 1. `ReturnIfAbrupt(status)`.
242-
> 1. Increase `k` by 1.
232+
> 1. Let `Pk` be `ToString(k)`.
233+
> 1. Let `kPresent` be `HasProperty(O, Pk)`.
234+
> 1. `ReturnIfAbrupt(kPresent)`.
235+
> 1. If `kPresent` is `true`, then
236+
> 1. Let `kValue` be `Get(O, Pk)`.
237+
> 1. `ReturnIfAbrupt(kValue)`.
238+
> 1. Let `mappedValue` be `Call(callbackfn, T, «kValue, k, O»)`.
239+
> 1. `ReturnIfAbrupt(mappedValue)`.
240+
> 1. Let `status` be `CreateDataPropertyOrThrow (A, Pk, mappedValue)`.
241+
> 1. `ReturnIfAbrupt(status)`.
242+
> 1. Increase `k` by 1.
243243
> 1. Return `A`.
244244
245245
翻译如下。
@@ -254,20 +254,20 @@ a2.map(n => 1) // [, , ,]
254254
> 1. 如果报错就返回
255255
> 1. 设定`k`等于 0
256256
> 1. 只要`k`小于当前数组的`length`属性,就重复下面步骤
257-
> 1. 设定`Pk`等于`ToString(k)`,即将`K`转为字符串
258-
> 1. 设定`kPresent`等于`HasProperty(O, Pk)`,即求当前数组有没有指定属性
259-
> 1. 如果报错就返回
260-
> 1. 如果`kPresent`等于`true`,则进行下面步骤
261-
> 1. 设定`kValue`等于`Get(O, Pk)`,取出当前数组的指定属性
262-
> 1. 如果报错就返回
263-
> 1. 设定`mappedValue`等于`Call(callbackfn, T, «kValue, k, O»)`,即执行回调函数
264-
> 1. 如果报错就返回
265-
> 1. 设定`status`等于`CreateDataPropertyOrThrow (A, Pk, mappedValue)`,即将回调函数的值放入`A`数组的指定位置
266-
> 1. 如果报错就返回
267-
> 1. `k`增加 1
257+
> 1. 设定`Pk`等于`ToString(k)`,即将`K`转为字符串
258+
> 1. 设定`kPresent`等于`HasProperty(O, Pk)`,即求当前数组有没有指定属性
259+
> 1. 如果报错就返回
260+
> 1. 如果`kPresent`等于`true`,则进行下面步骤
261+
> 1. 设定`kValue`等于`Get(O, Pk)`,取出当前数组的指定属性
262+
> 1. 如果报错就返回
263+
> 1. 设定`mappedValue`等于`Call(callbackfn, T, «kValue, k, O»)`,即执行回调函数
264+
> 1. 如果报错就返回
265+
> 1. 设定`status`等于`CreateDataPropertyOrThrow (A, Pk, mappedValue)`,即将回调函数的值放入`A`数组的指定位置
266+
> 1. 如果报错就返回
267+
> 1. `k`增加 1
268268
> 1. 返回`A`
269269
270-
仔细查看上面的算法,可以发现,当处理一个全是空位的数组时,前面步骤都没有问题。进入第 10 步的 ii 时`kPresent`会报错,因为空位对应的属性名,对于数组来说是不存在的,因此就会返回,不会进行后面的步骤。
270+
仔细查看上面的算法,可以发现,当处理一个全是空位的数组时,前面步骤都没有问题。进入第 10 步中第 2 步时`kPresent`会报错,因为空位对应的属性名,对于数组来说是不存在的,因此就会返回,不会进行后面的步骤。
271271

272272
```javascript
273273
const arr = [, , ,];

0 commit comments

Comments
 (0)