class Name { member = value; // but only constant assigns. member = value; constructor(params) { } name(params){ } ... }
this.data = datavalue.
get foo() { ... }
set foo() { ... }
let canvas = document.getElementById("polygons"); let ctx = canvas.getContext('2d'); let cx = canvas.width/2; let cy = canvas.height/2; let shapes = []; let r = 10; // build the shapes for(let sides =3; sides < 20; sides ++) { shapes.push(new Shape(sides, r)); r += 10; } // apply a random color to the shapes for(let i=0; i < shapes.length; i++) { shapes[i].RandomColor(); } // display the shapes. for (let i=0; i < shapes.length; i++) { shapes[i].Display(ctx, cx, cy); }