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
注意看规范中的NOTE 1: Typically, an array-like object would also have some properties with integer index names. However, that is not a requirement of this definition.
The text was updated successfully, but these errors were encountered:
lizhongzhen11
changed the title
Operations on Objects and Operations on Iterator Objects
重学js —— Operations on Objects and Operations on Iterator Objects
Jan 6, 2020
Operations on Objects and Operations on Iterator Objects
Object.seal
Object.freeze
类数组对象
注意看规范中的NOTE 1: Typically, an array-like object would also have some properties with integer index names. However, that is not a requirement of this definition.
翻译来看的话,类数组对象并不要求属性名必须是字符串类型的整数。 那么下面的也可以算类数组对象了:
GetIterator ( obj [ , hint [ , method ] ] )
如果 hint 不存在,设为 sync.
断言:hint 值为 sync 或 async.
如果 method 不存在,
如果 hint 是 async,
调用? GetMethod(obj, @@asyncIterator)将值赋给 method.
如果 method 是 undefined,
否则(如果 hint 是 sync),调用? GetMethod(obj, @@iterator)将值赋给 method.
定义过程变量 iterator,调用? Call(method, obj)将结果赋给 iterator.
执行Type(iterator),若结果不是对象,抛出类型错误
定义过程变量 nextMethod,调用? GetV(iterator, "next")将结果赋给 nextMethod
定义过程变量 iteratorRecord,其值为 Record { [[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false }
返回 iteratorRecord
IteratorNext ( iteratorRecord [ , value ] )
如果 value 不存在,
a. 定义 result 变量,调用 ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]])将结果赋给 result
否则,
a. 定义 result 变量,调用 ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »)将结果赋给 result
如果 result 类型不是对象,抛出类型错误
返回 result
IteratorComplete ( iterResult )
IteratorValue ( iterResult )
IteratorStep ( iteratorRecord )
ListIteratorNext Functions
匿名内置函数。
定义 O 保存 this 值
断言:O的类型是对象
断言:O有
[[IteratedList]]
内置插槽定义 list,值为 O.[[IteratedList]]
定义 index,值为 O.[[ListNextIndex]]
定义 len,值为 list 中的元素数量
如果 index >= len,
7.1 返回CreateIterResultObject(undefined, true)执行结果
设置 O.[[ListNextIndex]] 为 index + 1
返回CreateIterResultObject(list[index], false)执行结果
and so on...
The text was updated successfully, but these errors were encountered: