Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Multiplication operator (*)

The * operator computes the product of two values after numeric conversion. It supports Number and BigInt but does not allow mixing those types. Number multiplication requires attention to rounding and NaN.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

left * right

The * operator multiplies two operands: left * right. It has higher precedence than + and -, so 2 + 3 * 4 produces 14. The *, /, and % operators share a precedence level and group from the left. Parentheses let you change the grouping.

Before multiplication, JavaScript converts the operands to numeric values. Thus, "6" * 7 produces 42, while "six" * 7 produces NaN, not repeated text. Conversion can also throw an exception, for example for a Symbol value.

After conversion, both operands must have the same numeric type: Number or BigInt. The expression 6n * 7n produces 42n, but 6n * 7 throws TypeError. If conversion is needed, perform it explicitly, remembering that converting a large BigInt to Number can lose precision.

Multiplication of Number values follows binary floating-point limitations: the result may be rounded or overflow to Infinity. A NaN operand and multiplication of zero by Infinity produce NaN. Multiplication of two BigInt values produces the exact integer product.

Examples

console.log(6 * 7);
console.log("6" * 7);
console.log(String(6n * 7n));
console.log(Number.isNaN("six" * 7));
try {
  console.log(6n * 7);
} catch (error) {
  console.log(error.name);
}

Result

42
42
42
true
TypeError

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources