javascript: how to call variable instance inside variable? -
i trying make this:
var test = { a:function() { array = new array(); array[0] = new array("1","2","3"); array[1] = new array("name","age","blabla"); }, b: function() { var c = new this.a(); alert(c); //output:: object object alert(c.array[1]); // output:: undefined alert(c.array[1][0]); // output undefined } }
how can alerted example alert(c.array[1][0]) output "name". in other languages possible use methodes inherited classes in javascript. think(hope) it's possible, how?
painkiller
you'd have change a:
a:function() { this.array = new array(); this.array[0] = new array("1","2","3"); this.array[1] = new array("name","age","blabla"); },
if change it, you'd better this:
a:function() { this.array = [ [ "1", "2", "3" ], [ "name", "age", "blabla" ] ]; },
the "array" constructor pretty bad api design , should avoided.
Comments
Post a Comment