From 3e6cf8c39f492c0309fd9f6409fc4bda4891c1a0 Mon Sep 17 00:00:00 2001 From: Milk Lee Date: Thu, 23 Jul 2015 13:25:16 +0800 Subject: [PATCH] =?UTF-8?q?iterator.md=20=E4=B8=AD=E5=A4=9A=E5=A4=84?= =?UTF-8?q?=E5=B0=86=20Symbol=20=E9=94=99=E8=AF=AF=E7=9A=84=E5=86=99?= =?UTF-8?q?=E6=88=90=20System?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/iterator.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/iterator.md b/docs/iterator.md index d0c3ceb..56e2c2c 100644 --- a/docs/iterator.md +++ b/docs/iterator.md @@ -72,13 +72,13 @@ it.next().value // '2' 上面的例子中,遍历器idMaker函数返回的指针对象,并没有对应的数据结构,或者说遍历器自己描述了一个数据结构出来。 -在ES6中,有些数据结构原生提供遍历器(比如数组),即不用任何处理,就可以被for...of循环遍历,有些就不行(比如对象)。原因在于,这些数据结构原生部署了System.iterator属性(详见下文),有些没有。凡是部署了System.iterator属性的数据结构,就称为部署了遍历器接口。调用这个接口,就会返回一个指针对象。 +在ES6中,有些数据结构原生提供遍历器(比如数组),即不用任何处理,就可以被for...of循环遍历,有些就不行(比如对象)。原因在于,这些数据结构原生部署了Symbol.iterator属性(详见下文),有些没有。凡是部署了Symbol.iterator属性的数据结构,就称为部署了遍历器接口。调用这个接口,就会返回一个指针对象。 如果使用TypeScript的写法,遍历器接口(Iterable)、指针对象(Iterator)和next方法返回值的规格可以描述如下。 ```javascript interface Iterable { - [System.iterator]() : Iterator, + [Symbol.iterator]() : Iterator, } interface Iterator {