I'm trying to create three dimensional objects in JavaScript. I want to be able to run something like this:
object1().object2().object3();
but i don't want "object3()" to be able to be accessed like this:
object1().object3();
When i tried this:
function object1(){
alert("object 1");
function object2(){
alert("object 2");
function object3(){
alert("object 3");
}
}
}
It runs the first alert, but then chrome gives me this error:
TypeError: Object #<object1> has no method 'object2'
and when i tried this:
function object1(){
alert("object 1");
this.object2 = function(){
alert("object 2");
this.object3 = function(){
alert("object 3");
}
}
}
it runs the first two and then chrome gives me this error:
TypeError: Cannot call method 'object3' of undefined