R
Randell D.
Folks,
I have a Javascript performance question that I might have problems
explaining...
In PHP, better performance can be obtained dealing directly with a
variable, as opposed to an element in an array... Thus, if I have a
programming routine that utilises $a[1] several times, it is better to
write the value contained in $a[1] to something else, for example,
$vartmp, and have my routine instead use this for its work... I believe
its easier for the engine as it doesn't have to continually parse the
array for the value.
My question is, would this be the same in javascript... For arrays, and
objects...
Thus, if I have a client page/form called 'testForm', with an input tag
field name called 'firstname', which would be more efficient (in terms
of performance)... Would it be better to continually refer to
document.forms['testForm'].elements['firstname'].value
or
document.testForm.firstname.value
or
write one of the above into a string variable called firstname?
I know it would only be a slight performance advantage, but when one is
working on an intranet based application that could have a heavy
dependancy on javascript routines, and when the only thing I know about
my client is the browser name/version, I'm just trying to dot my Tee's
and cross my Eyes ;-)
All help, via the newsgroup (so all can learn), would be greatly
appreciated,
cheers
Randell D.
I have a Javascript performance question that I might have problems
explaining...
In PHP, better performance can be obtained dealing directly with a
variable, as opposed to an element in an array... Thus, if I have a
programming routine that utilises $a[1] several times, it is better to
write the value contained in $a[1] to something else, for example,
$vartmp, and have my routine instead use this for its work... I believe
its easier for the engine as it doesn't have to continually parse the
array for the value.
My question is, would this be the same in javascript... For arrays, and
objects...
Thus, if I have a client page/form called 'testForm', with an input tag
field name called 'firstname', which would be more efficient (in terms
of performance)... Would it be better to continually refer to
document.forms['testForm'].elements['firstname'].value
or
document.testForm.firstname.value
or
write one of the above into a string variable called firstname?
I know it would only be a slight performance advantage, but when one is
working on an intranet based application that could have a heavy
dependancy on javascript routines, and when the only thing I know about
my client is the browser name/version, I'm just trying to dot my Tee's
and cross my Eyes ;-)
All help, via the newsgroup (so all can learn), would be greatly
appreciated,
cheers
Randell D.