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
迭代器和生成器
const obj = {'a':'a','b':'b'}; // obj[Symbol.iterator] 是可迭代协议 obj[Symbol.iterator] = function() { const that = this; const keys = Object.keys(this); // 返回的对象则是迭代器协议 return { next: function() { if (this._idx !== keys.length) { return { value: that[keys[this._idx++]], done: false }; } else { return { done: true }; } }, _idx: 0, }; }; for (const element of obj) { console.log(element); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
迭代器和生成器
The text was updated successfully, but these errors were encountered: