Why does javascript accept commas in if statements?

后端 未结 5 1022
北荒
北荒 2020-11-29 23:47

I stumbled across some javascript syntax that seemed like it should produce a parse error of some kind but doesn\'t:

if (true, true) {console.log(\'splendid         


        
5条回答
  •  再見小時候
    2020-11-30 00:21

    This is also the same as in most other programming languages where you might have multiple iterators in a loop.

    int x,y;
    for(x = 0, y = 0; x < 10 || y < 100; x++, y++) {
    ....
    }
    

提交回复
热议问题