Skip to content Skip to sidebar Skip to footer

As3/javascript If Statement Commas Instead Of & &

This runs in ActionScript 3 and JavaScript. Why? I know how && and || work, but a list? Is this AS3 specific? Is this in other languages? I'm a mouth breathing PHP/AS2 prog

Solution 1:

I presume JavaScript has a comma operator like C, which takes multiple arguments and returns the last one. It's typically used to for loops where you want to initialize more than one value:

for(i=0, j=0; j< 10; j++) {  
...
}

Solution 2:

The comma is used to evaluate expressions in a sequence, the same thing could be done with parenthesis groups separated by &&

Post a Comment for "As3/javascript If Statement Commas Instead Of & &"