We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
什么是迭代器?迭代器就是一个具有next方法的对象,每次调用next返回一个对象,该对象具有两个属性,一个value值和一个done值,done为true表示迭代结束。 模拟一个迭代器
true
function createIterator(items) { var len = items.length var i = 0 return { next: function() { value = items[i++] done = i > len ? true : false return { value: value, done: done } } } } const iterate = createIterator([1,2,3]) console.log(iterate.next()) console.log(iterate.next()) console.log(iterate.next()) console.log(iterate.next())
The text was updated successfully, but these errors were encountered:
No branches or pull requests
迭代器
什么是迭代器?迭代器就是一个具有next方法的对象,每次调用next返回一个对象,该对象具有两个属性,一个value值和一个done值,done为
true
表示迭代结束。模拟一个迭代器
The text was updated successfully, but these errors were encountered: