The function you pass to each has a second optional index param:
$$('.foo').each(function(elem, index) {
elem.update('I am element ' + index);
});
It's not all that clear in the docs but it's mentioned for the
iterator param here:
http://api.prototypejs.org/language/Enumerable/prototype/each/
Hi,
I could swear there used to be an operator that worked over an
enumerable and maintained an index element as you went...
As Marc's pointed out that `each` does have the index as the second
parameter. But using `each` for this introduces unnecessary function
creation, function calls, and
On Tue, Feb 1, 2011 at 12:35, T.J. Crowder t...@crowdersoftware.com wrote:
(now that `$break` has been deprecated).
$break has been deprecated? Where is that documented?
What are we supposed to use instead?
--
Bertilo Wennergren
berti...@gmail.com http://bertilow.com
--
You received this
Yes, exactly! I knew it was in there somewhere, but I couldn't find
the ref.
Walter
On Feb 1, 2011, at 3:37 AM, Marc wrote:
The function you pass to each has a second optional index param:
$$('.foo').each(function(elem, index) {
elem.update('I am element ' + index);
});
It's not all that
It's curiously that not declare two dimensional array in prototype.
It's nothing to do with Prototype. Javascript (like many scripting
languages) doesn't have two-dimensional arrays.
You can simulate them with arrays of arrays, but an initialiser has to
be specific: if you are going to want a
Hi,
$break has been deprecated?
Yup.
Where is that documented?
I don't know, I only know because Tobie mentioned it to me once. I'm
sure it's mentioned in a thread here somewhere. You'll note it's
disappeared from the documentation. ECMAScript 5th edition's `forEach`
(which is pretty much