Creating an array of custom objects

Hi all,

I have created a custom class of my own in javascript with attributes as shown below:

class ConceptNode{ //node to store concept/relation

static var concept = "";
static var activity = -1;
static var activated = false;
static var hyperConceptOf = new Array();
static var elementConcept = new Array();

function ConceptNode(con,act,hyper,ele){//constructor
	this.concept = con;
	this.activity = act;	
	hyperConceptOf.push(hyper);
	elementConcept.push(ele);		
}

}

I then try to create an array of objects of the above class in another script which is attached to a GameObject using the following:

static var conceptList = new Array(); static var conceptNodeList = new Array();

function Update(){

}

function Start(){

conceptNodeList[0] = new ConceptNode("Landmark",0,"","Building");</p>

conceptNodeList[1] = new ConceptNode("Building",0,"Landmark","Commercial");

for(var i=0;i<conceptNodeList.length;i++){
	Debug.Log(conceptNodeList*.concept);*
_	Debug.Log(conceptNodeList*.hyperConceptOf[0]);*_
_*}*_
_*```*_
_*<p>}</p>*_
_*<p>It seems that both the ConceptNode objects which I've created in the conceptNodeList are the same object. The log messages show the same attributes for both iterations. is this due to javascript array passing by reference? Or am I doing something wrongly? Any help by anyone would be greatly appreciated.</p>*_
_*<p>Thank you</p>*_

Your variables shouldn't be static. static variables are the same for every instance of a class, which is why you're getting the same values no matter which instance you access. Just change this:

static var concept = "";
static var activity = -1;
static var activated = false;
static var hyperConceptOf = new Array();
static var elementConcept = new Array();

To this:

var concept = "";
var activity = -1;
var activated = false;
var hyperConceptOf = new Array();
var elementConcept = new Array();

Unless of course you actually need any of those variables to be static.