📅  最后修改于: 2022-03-11 15:00:31.291000             🧑  作者: Mango
class Polygon {
constructor(...sides) {
this.sides = sides;
}
// Method
*getSides() {
for(const side of this.sides){
yield side;
}
}
}
const pentagon = new Polygon(1,2,3,4,5);
console.log([...pentagon.getSides()]); // [1,2,3,4,5]