[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Multiplication [Back]  [Original]

(*) - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

(*)

Baseline

20157

(*)

console.log(3 * 4);
// : 12

console.log(-3 * 4);
// : -12

console.log("3" * 2);
// : 6

console.log("foo" * 2);
// : NaN

js
x * y

* 2 TypeError

js
2 * 2; // 4
-2 * 2; // -4

Infinity * 0; // NaN
Infinity * Infinity; // Infinity

js
"foo" * 2; // NaN
"2" * 2; // 4

js
2n * 2n; // 4n
-2n * 2n; // -4n

js
2n * 2; // TypeError: Cannot mix BigInt and other types, use explicit conversions
2 * 2n; // TypeError: Cannot mix BigInt and other types, use explicit conversions

js
2n * BigInt(2); // 4n
Number(2n) * 2; // 4

ECMAScript 2027 LanguageSpecification
# sec-multiplicative-operators


Web Proxy Viewer  |  New URL  |  Original Page