I wrote the code in Java, no problem. Here I am giving the Java code:
public class CarGallery {
static int carCounter=10;
static Gallery[] car = new Gallery[carCounter];
public static void main(String[] args) {
car[0].weight = (float) 1.25;
car[0].weight = (float) 0.87;
// ... and so on ... //
}
}
class Gallery {
public float weight;
public float height;
public int colorCode;
public int stockGallery;
};
The thing is, I want to write the same code in Javascript. Here is the code that does not work:
var cars = {weight:0 , height:0 , stock:0 , model:"..."};
var cars = new Array();
cars[0].weight=1.2;
cars[0].height=0.87;
cars[0].stock=2;
cars[0].model="320";
- I read some documents and saw that there is no class definition in Javascript like Java classes.
- I found class definition in JS with constructors, but I don't want to use constructors.
The member should be defined as array like:
static Gallery[] car = new Gallery[carCounter];
Thank you for your help!