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 y
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
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
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?
On Jun 25, 3:13 pm, Christof Donat <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > Okay, thanks for the help. I was just trying
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'
}
functio
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=funct
Hi,
> C++
>
> ...
> (new Container()).containedObj.method1();
> //How could method1 ever access varA?
>
OOps, this shopuld of course read
(new Container())->containedObj.method1();
Christof
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
8 matches
Mail list logo