迭代器模式顺序访问一个对象的 对象的内部可分为内部迭代器 和 外部迭代器内部迭代器就是常见的 forEach(), 或者 $.each()function forEach(arr, callback) { var i = 0, len = arr.length; for (; i < len; i++) { callback && callback(arr[i]) }}外部迭代器ES6 实现了 Iterator// 简单 实现 Iteratorlet Iterator = function(obj) { let current = 0; let next = function() { current += 1; } let isDone = function() { return current > obj.length; } let getCurrentItem = function() { return obj[current]; } return { next: next, isDone: isDone, getCurrentItem: getCurrentItem, length: obj.length }}