We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
可以使用逗号运算符在一行中计算多个表达式。它从左到右求值,并返回右边最后一个项目或最后一个操作数的值。
逗号
let x = 5; x = (x++ , x = addFive(x), x *= 2, x -= 5, x += 10); function addFive(num) { return num + 5; }
上面的结果最后得到x的值为27。首先,我们将x的值增加到6,然后调用函数addFive(6)并将6作为参数传递并将结果重新分配给x,此时x的值为11。之后,将x的当前值乘以2并将其分配给x,x的更新值为22。然后,将x的当前值减去5并将结果分配给x x更新后的值为17。最后,我们将x的值增加10,然后将更新的值分配给x,最终x的值为27。
x
27
6
addFive(6)
11
2
22
5
17
10
The text was updated successfully, but these errors were encountered:
No branches or pull requests
可以使用
逗号
运算符在一行中计算多个表达式。它从左到右求值,并返回右边最后一个项目或最后一个操作数的值。上面的结果最后得到
x
的值为27
。首先,我们将x
的值增加到6
,然后调用函数addFive(6)
并将6
作为参数传递并将结果重新分配给x
,此时x
的值为11
。之后,将x
的当前值乘以2
并将其分配给x
,x
的更新值为22
。然后,将x
的当前值减去5
并将结果分配给x
x
更新后的值为17
。最后,我们将x
的值增加10
,然后将更新的值分配给x
,最终x
的值为27
。The text was updated successfully, but these errors were encountered: