Tekkaman

导航

 

Javascript Iterator

1、@@iterator

  Whenever an object needs to be iterated (such as at the beginning of a for..of loop), its @@iteratormethod is called with no arguments, and the returned iterator is used to obtain the values to be iterated.

  

  示例:

  

  指定的方法必须是funtion*,否则出错

  

2、for...of

  Whenever an object needs to be iterated (such as at the beginning of a for..of loop), its @@iteratormethod is called with no arguments, and the returned iterator is used to obtain the values to be iterated.

3、The iterator protocol

  

参考:

1、https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator

2、https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols

posted on 2017-02-10 15:00  Tekkaman  阅读(209)  评论(0编辑  收藏  举报