class Counter {
constructor(max) {
this.max = max;
}
*[Symbol.iterator]() {
let current = 0;
while (current < this.max) {
yield current++;
}
}
}
const counter = new Counter(3);
const result = [...counter, ...counter];
console.log(result);
Ответ:
Please open Telegram to view this post
VIEW IN TELEGRAM