我发现用括号括起来不同的语句将返回最后一个:
(34892,47691876297,2000) => 2000
('test',73,document.createElement('p')) => <p></p>
而且我还发现所有的语句都被执行了:
(console.log('test'), console.log('test2'), console.log('test3'), 6)
将记录:
test
test2
test3
结果将是 6。
但是,我也发现有些语句不能用:
(throw new Error(), 10) => SyntaxError: Unexpected token throw
(if (1) console.log('test'), 5) => SyntaxError: Unexpected token if
那么,这个括号逗号符号的意义何在?您可以轻松地执行所有语句,然后使用最后一条语句的值。这个是来做什么的?我使用不正确吗?