【发布时间】:2012-11-16 21:33:07
【问题描述】:
我正在尝试使用 javascript 来选择两个数字中的较大者。我知道我可以写一个 if 语句,但我想知道是否有某种数学运算或其他东西可以提高效率。下面是我如何使用 if 语句:
if (a > b) {
c = a;
}
else {
c = b;
}
【问题讨论】:
-
c = a > b ? a : b;,max(a,b)?
标签: javascript jquery math comparison comparison-operators