- Home /
Arrays and Classes javascript
Here is a class Card and a 2d array aGrid.
The 2d array aGrid is set to aGrid = new Card[4,4]
; it looks like I am making it an instance of the Card class and an array at the same time. How does this work??
I thought a variable could only be set to one type of thing ---> an object instance or an array but not both.
Here is the code:
class Card extends System.Object {
var isFace:boolean = false;
var isMatched:boolean = false;
}
var aGrid:Card[,];//2d array to keep track of the shuffled, dealt cards
var aGrid = new Card[4,4];
This question seems to suffer from multiple personality disorder.
Does the OP know arrays
I know arrays...
or not
I don't underwhat what Card[x,y] does
Does the OP own this code
var aGrid = new Card[rows,cols];
or not
Why is new Card used????
Does the OP need an instance
I'm not making an instance of the Card class
or not
var aGrid = new Card[rows,cols];
Oh lol. I worded it really badly can you look over the question again.
Answer by huntsfromshadow · Mar 27, 2014 at 01:37 PM
I would highly suggest you step back and learn the Javascript arrays and classes as they are important to coding.
http://www.codecademy.com/ is a wonderful source with great interactive tutorials that will teach you Javascript.
I worded the question really badly could you please look it over again :)