G
Gerald S
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") ??
Version Inline:
item = function () {
this.myMethod1 = function() { .. }
this.myMethod2 = function() { .. }
this.myMethod3 = function() { .. }
...
this.myMethod999 = function() { .. }
}
Version Prototype:
item = function () {
}
item.prototype.myMethod1 = function() { .. }
item.prototype.myMethod2 = function() { .. }
item.prototype.myMethod3 = function() { .. }
...
item.prototype.myMethod999 = function() { .. }
many thanks in advance !!
-
Gerald Stampfel
(e-mail address removed)
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") ??
Version Inline:
item = function () {
this.myMethod1 = function() { .. }
this.myMethod2 = function() { .. }
this.myMethod3 = function() { .. }
...
this.myMethod999 = function() { .. }
}
Version Prototype:
item = function () {
}
item.prototype.myMethod1 = function() { .. }
item.prototype.myMethod2 = function() { .. }
item.prototype.myMethod3 = function() { .. }
...
item.prototype.myMethod999 = function() { .. }
many thanks in advance !!
-
Gerald Stampfel
(e-mail address removed)