Javascript “tuple” notation: what is its point?

后端 未结 3 1515
庸人自扰
庸人自扰 2020-12-24 12:44

At wtfjs, I found that the following is legal javascript.

\",,,\" == Array((null,\'cool\',false,NaN,4)); // true

The argument (null,\

3条回答
  •  一生所求
    2020-12-24 13:12

    You are seeing the effect of the comma operator.

    The comma operator evaluates both of its operands (from left to right) and returns the value of the second operand.

    The resultant value when a,b,c,...,n is evaluated will always be the value of the rightmost expression, however all expressions in the chain are still evaluated (from left to right).

提交回复
热议问题