Gerald S wrote:
> hi,
>
> got a performance problem; situation is as described below (see "Version
> Inline"), i've got a javascript class item with many methods defined
> inside and with every call to "new item()" the js interpreter has to
> look through all the method definitions (did a profile using Venkman)
> which takes too much time for me ..
>
> would it make a difference if i define these methods outside the
> constructor via .prototype (see "Version Prototype") ??
>
Yes it will make a difference since you will only be setting up the methods
once instead of every time you create an object, also if you have a lot of
objects you will be using less memory so there may be a gain there. Calls
to the methods may be slightly slower but that is unlikely to be
noticeable.
Received on Tue Feb 7 21:28:38 2006