Okay, thanks for the help. I was just trying to figure out how to do inheritence in javascript and instead embedded objects inside other objects. :)
One solution I found was something like this: function Contained () { var self=this; self.var1=1; self.var2=2; self.method1=function () { return (self.varA); }; } function Container () { var self=this; self.varA = 'a'; self.varB = 'b'; self.containedObj = new Contained; self.containedObj.varA = self.varA; self.containedObj.varB = self.varB; } On Jun 25, 9:42 am, Gordon <[EMAIL PROTECTED]> wrote: > I am tryign to make more use of OOP techniques in JavaScript, but most > of the OOP I have done up to now has been in class-based languages, > and I'm struggling a little with the prototype based approach used in > javascript. I know this isn't a jQuery specific question but you guys > seem like the people to ask on these things. :) > > The problem is like this. Suppose I have one object that uses another > object as a variable inside it, like so: > > function Contained () > { > var self=this; > self.var1=1; > self.var2=2; > self.method1=function () > { > }; > > } > > function Container () > { > var self=this; > self.varA = 'a'; > self.varB = 'b'; > self.containedObj = new Contained; > > } > > var foo = new Container; > > Now suppose I want to access variables of Container from within > Contained, for example I might want method1 to return the value of > varA in Container. How would I go about doing this?