Heh, nope. Sorry I guess it is just a VBScript thing... lemmie try to
explain how it would be used...
function MyObject() {
this.x = 0;
this.y = 0;
this.getSum = function(a, b) {
this.x = a;
this.y = b;
return(x + y);
}
}
if getSum() were set to a be the default method then you could use...
o = new MyObject();
sum = o(3, 5);
this should put the value 8 in sum, if there was a way to set "getSum" as
the default method.
In a way, toString() is a default method. If it exists it gets called
anytime a string type is expected.
does that explain better what I am looking for?
-- Matthew
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Josep Monés
i Teixidor
Sent: Friday, February 02, 2001 7:27 PM
To: [EMAIL PROTECTED]
Subject: RE: [Dynapi-Help] JavaScript Question
I would swear that C++ hasn't got such an strange thing (VB you say?).
Couldn't you have been confused by the default constructor that the compiler
provides when you don't supply one?
Returning to the original question, i think this doesn't exist. Why can't
you call a function "default" or something like that consistently in all
your objects?
I wonder why could it be useful. Do you want to change it on the fly? I
believe you could do:
MyObject.prototype.function1=function() { bla bla bla };
MyObject.prototype.function2=function() { bla bla bla };
and then:
MyObject.prototype.default = MyObject.prototype.function1;
and change it on the fly using:
MyObject.prototype.default = MyObject.prototype.function2;
Is this what you need?
Regards,
Josep
-----Mensaje original-----
De: Doug Melvin <[EMAIL PROTECTED]>
Para: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Fecha: sábado 3 de febrero de 2001 3:09
Asunto: Re: [Dynapi-Help] JavaScript Question
>It's C++ thing.
>
>As far as I know a javascript object can not have a default method
>
>Doug
>----- Original Message -----
>From: "Jack_Speranza" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Friday, February 02, 2001 2:17 PM
>Subject: RE: [Dynapi-Help] JavaScript Question
>
>
>> OK, I'm really gonna show my ignorance here... what do you mean by a
>> "default" method?
>>
>> -----Original Message-----
>> From: Matthew Alan Shirey [mailto:[EMAIL PROTECTED]]
>> Sent: Friday, February 02, 2001 4:58 PM
>> To: Dynapi-Help
>> Subject: [Dynapi-Help] JavaScript Question
>>
>>
>> Hey all,
>>
>> This isn't really DynAPI related but it is JS related.
>> Is there a way to define a default method for a JavaScript object?
>VBScript
>> has this ability but so far I have not been able to find the same thing
in
>> JavaScript...
>>
>> Thanks,
>>
>> -- Matthew
>>
>>
>> _______________________________________________
>> Dynapi-Help mailing list
>> [EMAIL PROTECTED]
>> http://lists.sourceforge.net/lists/listinfo/dynapi-help
>>
>> _______________________________________________
>> Dynapi-Help mailing list
>> [EMAIL PROTECTED]
>> http://lists.sourceforge.net/lists/listinfo/dynapi-help
>
>
>_______________________________________________
>Dynapi-Help mailing list
>[EMAIL PROTECTED]
>http://lists.sourceforge.net/lists/listinfo/dynapi-help
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help