What does a comma do in JavaScript expressions?

前端 未结 5 1564
礼貌的吻别
礼貌的吻别 2020-11-21 05:22

If I use:

1.09 * 1; // returns \"1.09\"

But if I use:

1,09 * 1; // returns \"9\"

I know that 1,09 isn\'t

5条回答
  •  一个人的身影
    2020-11-21 05:50

    Have a look here - the comma stands for multiple expressions / statements. For example in your code you could use a line like this:

    var a=0, b=0, c=0;
    

    This would declare all three variables without writing:

    var a=0;
    var b=0;
    var c=0;
    

    Hope that helps.

提交回复
热议问题