On Nov 12, 4:27 pm, Matt Foster <[EMAIL PROTECTED]> wrote:
> A little lost on what the question is, but I took an assumption and
> ran with it.  The idea of stacking these methods was intriguing.
> Check out this code, its pretty useless really but an interesting
> example of object ownership and function delegation.
>
> var MyClass = function(){
>         this.name = "Matt";
>         this.speak = function(){
>                 alert(this.name);
>         }}

It's a good idea to put `speak` on prototype (for efficiency reasons),
unless it needs to have an access to local variables of constructor
(e.g. for making `privileged` methods) : )

MyClass.prototype.speak = function(){
  alert(this.name);
}

[...]

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to