admin管理员组

文章数量:1323342

var x = (1,2,3);
alert(x);

This expression evaluates to 3.

How is this expression (1,2,3) called? Why does it return 3?

var x = (1,2,3);
alert(x);

This expression evaluates to 3.

How is this expression (1,2,3) called? Why does it return 3?

Share Improve this question edited Jun 9, 2015 at 15:56 Felix Kling 817k181 gold badges1.1k silver badges1.2k bronze badges asked Mar 5, 2011 at 1:56 DrStrangeLoveDrStrangeLove 11.6k16 gold badges63 silver badges73 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 13

Javascript has a ma operator, like C does. It evaluates each of the expressions, then returns the last one.

I haven't seen this in Javascript before. But in a number of other C'ish languages, it basically evaluates each of the expressions in the parentheses and returns the value of the last one.

本文标签: Javascript expression in parenthesesStack Overflow