Skip to content
Advertisement

How do i initialise an array of object in constructor in JavaScript

I would like to create a class with an array of object in the constructor. The idea is to create rects in a canvas with the values inside the objects.

I have this array:

JavaScript

I tried the following:

JavaScript

Thanks for your help.

Advertisement

Answer

As already written, the addition of this works. See example with this.boxs

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement