相乘運算子(*)
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
相乘運算子(*
)是用來取得兩個運算元的乘積。
嘗試一下
語法
js
x * y
範例
乘以數字
js
2 * 2; // 4
-2 * 2; // -4
乘以無限(Infinity)
js
Infinity * 0; // NaN
Infinity * Infinity; // Infinity
乘以非數字
js
"foo" * 2; // NaN
規範
Specification |
---|
ECMAScript Language Specification # sec-multiplicative-operators |
瀏覽器相容性
BCD tables only load in the browser