Hi,
Thanks, that's really great, I'll have to really play around with that
when I've got the time to really get to grips with it. Can you do
multiple inheritence with that trick?
That is not a trick, but a usuall JavaScript idiom.
You can simulate multiple inheritance as well, but then you
Hi,
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;
Hi,
C++
...
(new Container()).containedObj.method1();
//How could method1 ever access varA?
OOps, this shopuld of course read
(new Container())-containedObj.method1();
Christof
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;
Hi,
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. :)
Ah, what you are looking for is this:
function super() { /*...*/ };
super.prototype = {
varA: 'a',
varB: 'b'
}
function
On Jun 25, 6:42 pm, 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
On 6/25/07, Christof Donat [EMAIL PROTECTED] wrote:
Hi,
C++
...
(new Container()).containedObj.method1();
//How could method1 ever access varA?
OOps, this shopuld of course read
(new Container())-containedObj.method1();
Christof
I don't post much, but I must say that's
7 matches
Mail list logo