August 11, 200520 yr I'm just curious about this. Let's say I have an array of ten objects and a boolean called "isRunning." Is there a way to test the whole array for this boolean? In other words, instead if saying "if(object[0].isRunning==true && object[1].isRunning==true && object[2].isRunning==true && ... etc)" and instead of creating a for loop, is there a way to be like... "if(object[0-9].isRunning==true)"? Address all objects in an array or something similar?
August 11, 200520 yr http://developer.mozilla.org/en/docs/Co ... rray:every Mozilla/Gecko specific JS extension. I'm betting java has a similar thing though, but alas I don't know java :(
August 11, 200520 yr I'm just curious about this. Let's say I have an array of ten objects and a boolean called "isRunning." Is there a way to test the whole array for this boolean? In other words, instead if saying "if(object[0].isRunning==true && object[1].isRunning==true && object[2].isRunning==true && ... etc)" and instead of creating a for loop, is there a way to be like... "if(object[0-9].isRunning==true)"? Address all objects in an array or something similar? Have to use a for loop. You can only access one variable at a time during a value comparison. not like a for loop would be much more effort anways...
August 11, 200520 yr Author http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:every Mozilla/Gecko specific JS extension. I'm betting java has a similar thing though, but alas I don't know java :( Ooh, that's cool. Well, no worries, I don't know much about JavaScript. =P Have to use a for loop. You can only access one variable at a time during a value comparison. not like a for loop would be much more effort anways... Oy, okay, thanks. Yeah, it's not much effort, it's just that something I was writing up awhile ago wasn't working with a for loop. It was so long ago that I can't even remember what it was--I've just always had the question since then, haha. It was a situation where everything needed to be checked together, which is why the other option was writing out every object in an if statement.
August 11, 200520 yr Hannibal: Can't use JavaScript API much for Java. Gotta use the Java API ;) And just for the record, there is no function like every() within the Java API that I can find. Least not for generic use anyways... You could write your own, but it'd have to contain a for loop anways so meah :P
August 12, 200520 yr Author You could write your own, but it'd have to contain a for loop anways so meah :P Okay, point taken, I can't avoid the for loop. :P
August 12, 200520 yr Hannibal: Can't use JavaScript API much for Java. Gotta use the Java API ;) And just for the record, there is no function like every() within the Java API that I can find. >_> I'm well aware JavaScript won't work in a Java environment, just saying I expected the javascript function to have a base in either Java or C(++). As said, I don't 'know' Java. So I was just suggesting to look in a direction like that :P
Create an account or sign in to comment