I have an array of objects and I'm trying to iterate through each object in the array. I need to call a method on each object. How should I go about doing this?
function basicBox(x,y,width,height,color) {
    this.color = color;
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;
    this.draw = function() {
        g.drawStyle = this.color;
        g.drawRect(this.x,this.y,this.width,this.height);
    }
}
var boxes = [b1,b2,b3];
function run() {
    for (var i = 0; i < boxes.length; ++i) {
        boxes[i].update();
    }
}
 
     
    