I've been trying to create a tree module in JavaScript for implementing a "family tree" style structure. I'm not very experienced in newer JavaScript design styles and want to make sure I am going along the right path with the code I have written so far. Can someone let me know if I am on the right track with how this is organized?
var TREE = (function() {
var treeList = [], //Tree container
//Constructor for Member object
Member = function(name, mother, father, children){
this.name = name || null;
this.mother = mother || null;
this.father = father || null;
this.children = children || null;
},
//Constructor for Tree object
Tree = function(name){
this.name = name || null;
this.memberList = [(new Member("root"))];
};
//Tree methods
Tree.prototype.addMember = function(name, mother, father, children){
this.memberList.push(new Member(name, mother, father, children));
}
Tree.prototype.getMemberList = function(){
return this.memberList;
}
return {
create : function(treeName){
treeList.push(new Tree(treeName));
return treeList[treeList.length - 1];
},
getTreeList : function(){
return treeList;
}
};
}());