1class Polygon {
2 constructor(...sides) {
3 this.sides = sides;
4 }
5 // Method
6 *getSides() {
7 for(const side of this.sides){
8 yield side;
9 }
10 }
11}
12
13const pentagon = new Polygon(1,2,3,4,5);
14
15console.log([...pentagon.getSides()]); // [1,2,3,4,5]
16