I\'m learning JavaScript using W3C and I didn\'t find an answer to this question.
I\'m trying to make some manipulations on array elements which fulfill some conditi
You can use for ... in
in JavaScript:
for (var key in array) {
if (/* some condition */) {
// ...
}
}
As of JavaScript 1.6, you can use this, too:
for each (var element in array) {
// ...
}
These are mainly meant to traverse object properties. You should consider to simply use your for
-loop.
EDIT: You could use a JavaScript framework like jQuery to eliminate these cross-browser problems. Give it a try. Its $.each()-method does the job.