Hi,

> If I want to quickly develop without looking up whether I need NEW or
> don't need NEW, can I just put NEW in front of everything?

Surely it's better to have an idea what you're actually using, a
function or a constructor?  There aren't that many effects.  If you
use `new` inappropriately, you will at least cause unnecessary
temporary memory allocations, and at worst introduce avoidable bugs in
your code.
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Aug 22, 10:09 pm, JoJo <tokyot...@gmail.com> wrote:
> If I want to quickly develop without looking up whether I need NEW or
> don't need NEW, can I just put NEW in front of everything?  Would this
> lead to a memory leak or does Prototype have some sort of garbage
> collection?
>
> On Aug 20, 2:04 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
>
>
>
> > Hi,
>
> > In general, the correct thing is what the docs[1] say it is.  Fade,
> > Appear, and most others are just functions, not constructor functions,
> > and so "new" is not correct.  Some other things, like Effect.Opacity
> > [2] (which confusingly use *exactly* the same capitalization -- don't
> > shoot the messenger), are constructor functions, and so you need to
> > use "new" with them.  When in doubt, check the docs.  I don't know
> > scripty well enough to know why some of them are constructors and some
> > aren't; perhaps there's a good reason...
>
> > If you use the methodized form instead:
>
> >     $('myNiftyFadingElement').fade();
>
> > ...you don't have to worry about it.
>
> > [1]http://wiki.github.com/madrobby/scriptaculous/effect-fade
> > [1]http://wiki.github.com/madrobby/scriptaculous/effect-opacity
>
> > HTH
> > --
> > T.J. Crowder
> > tj / crowder software / com
> > Independent Software Engineer, consulting services available
>
> > On Aug 20, 7:29 am, Mojito <tokyot...@gmail.com> wrote:
>
> > > Which is more proper?
>
> > > new Effect.Fade(......)
>
> > > or
>
> > > Effect.Fade(......)
>
> > > Both work for me. I'm just wondering which one is more cross browser
> > > compatible or runs faster.
--~--~---------~--~----~------------~-------~--~----~
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 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to