static - means defined in object's prototype? but what difference between foo, which decleared in prototype, and so called static method bar? which is also decleared in prototype?
On 24 май, 16:55, "T.J. Crowder" <[email protected]> wrote: > On May 24, 2:39 pm, buda <[email protected]> wrote: > > > Why Class.create produces only instance methods but not prototype > > ones? > > `Class.create` *does* create methods on the prototype: > > var C = Class.create({ > foo: function() { > } > > }); > > display("typeof C.prototype.foo == " + typeof C.prototype.foo); > // "typeof C.prototype.foo == function" > > Live copy:http://jsbin.com/ajifi5 > > Do you mean static methods? E.g., C.methodName? `Class.create` doesn't > do them, but they're easy to add either directly or via > `Object.extend`: > > Object.extend(C, { > bar: function() { > } > > }); > > display("typeof C.bar == " + typeof C.bar); > // "typeof C.bar == function" > > Live example:http://jsbin.com/ajifi5/2 > > (Side note: I'm using anonymous functions above, which I don't > actually like very much.[1] But I didn't want to introduce scoping > functions and such.) > > [1]http://blog.niftysnippets.org/2010/03/anonymouses-anonymous.html > > HTH, > -- > T.J. Crowder > Independent Software Engineer > tj / crowder software / com > www / crowder software / com -- 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 [email protected]. 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.
