Hello all
sorry for this stupid question, but all these talks about the *this
pointer and the variable
scope in js got me confused.
support I have 2 functions, one calling the other inside array iteration.
can they both
use the same local variable for array index ?
should I use a var statement ?
Hi there,
there are not stupid questions of course. They could be a bit more
prototype-related though...
All you should have to do is use var in order to make a variable
local to the function it is declared in. In your example that would
be:
for(var i=0;iarray_b_length;i++)
On Wed, Jan 19, 2011
Do you try to access the same variable in both functions?
If yes you could pass the function A array length to function B or bind it
to function B.
Cheers,
Ngoc
--
Blog: http://blog.nhdoan.de
Magento: http://demo.mage.nhdoan.de
Am 19.01.2011 um 14:31 schrieb Ran Berenfeld:
Hello all
And last but not least, if this is a prototype mailing list you should
of course use prototype, so your loops would look like this:
$A(array_b_length).each(function(arrayElement) {
// do something with the element...
});
--
You received this message because you are subscribed to the Google