function dTree() {
return {
init : function(data) {
this.data = data;
},
node : function(i){
return '' + i;
}
}
};
dTree.prototype.toString = function() {
var str = '';
for(var i = 0; i < this.data.length; i++)
{
str += this.node(this.data[i]);
};
return str;
}
dTree1 = new dTree();
dTree1.init([1,2,3]);
alert(dTree1+'')
I'm expecting it to output 123
How to do it the right way?