ECMAScript仕様輪読会 #57
前回: ECMAScript仕様輪読会 #56
Scrapboxの招待リンク: https://scrapbox.io/projects/esspec/invitations/85b96c9fa718ce5185e307196ed8fb53
connpass: https://esspec.connpass.com/
Discord: https://discord.gg/59S3y6weQj
ES Spec Draft: https://tc39.es/ecma262/
読み物リスト
Twitter hashtag: #esspec
21:01 再開
便利ツール
esspec-memo: https://tars0x9752.github.io/esspec-memo/esspec.html
Scrapbox Codeblock Generator: https://vzvu3k6k.github.io/scrapbox-codeblock/
TC39 Terminology: https://github.com/tc39/how-we-work/blob/main/terminology.md
時事ネタ
https://github.com/tc39/agendas
https://github.com/tc39/notes
https://github.com/tc39/proposals
自己紹介 (近況報告)
syumai syumai.icon
Twitter: https://twitter.com/__syumai GitHub: https://github.com/syumai
Go / TSを書いて暮らしてます
伊勢に行きました
tars0x9752 (たーず / naoki aoyama) tars0x9752.icon
https://github.com/tars0x9752
iwatsurut
とくに、イベントもなく過ごしています。
js の話題ではないが、kyoto.go に参加しました。
ご参加ありがとうございました!yebis0942.icon
前回のあらすじ
今回の範囲
Iterator
code:js
function makeRangeIterator(start = 0, end = Infinity, step = 1) {
let nextIndex = start;
let iterationCount = 0;
const rangeIterator = {
next: function () {
let result;
if (nextIndex < end) {
result = { value: nextIndex, done: false };
nextIndex += step;
iterationCount++;
return result;
}
return { value: iterationCount, done: true };
},
};
return rangeIterator;
}
const obj = {
Symbol.iterator: () => makeRangeIterator(1, 10, 2)
}
for (const value of obj) {
console.log(value); // 1 3 5 7 9
}
code:js
const end = 10;
let i = 0;
const it = {
next: function () {
if (i < end) {
i += 1;
return {};
}
return { done: true };
},
};
const obj = {
Symbol.iterator: () => it,
};
for (const value of obj) {
console.log(value);
}