how can you make a multi dimensional object??
function tst(){
this.a = function(){
alert(this.b.abc.c());
};
this.b = function(){
};
}
var obj = new tst();
obj.b.abc = function(){
this.c = function(){
return 'hello world';
};
};
obj.a();
The problem is with this code:
Calling the
abcfunction will not create aobj.b.abc.cfunction, but aobj.b.cfunction. Therefore,this.b.abc.c()throws an error because such a function doesn’t exist.This will make it work:
Live demo: http://jsfiddle.net/vgpNU/