What does a comma do in assignment statements in JavaScript?

前端 未结 4 1177
盖世英雄少女心
盖世英雄少女心 2020-12-10 14:32

I found this in a piece of code and i\'m wondering what it does? Assign b to x... but what\'s with the ,c?

var x = b, c;
4条回答
  •  不知归路
    2020-12-10 14:58

    It's the same as

    var x = b;
    var c; 
    

    One of those so clever it's extremely stupid additions to a language.

提交回复
热议问题