Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Multiplication assignment (*=)

The *= operator multiplies a variable's or property's current value by the right operand and assigns the computed product. The expression yields that product, which may differ from the value actually stored. The operator supports Number and BigInt but does not allow mixing those types.

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

target *= expression

target *= expression reads the target's value, evaluates the right operand, performs multiplication, and assigns the computed product to the same target. The value of the whole expression is the computed product: the operator does not read the target back after assignment. For example, if items is a Uint8Array and items[0] is 200, items[0] *= 2 evaluates to 400, but the element stores 144. The target must be a valid assignment location, such as a variable or object property; assigning to a variable declared with const throws TypeError.

For a simple variable, x *= y behaves like x = x * y, but this is not a safe general rewrite: the left side of *= is evaluated only once. This matters with function calls or indices with side effects; for example, items[i++] *= 2 increments i only once.

Multiplication applies numeric conversion: "5" multiplied by 3 produces the number 15, not repeated text. After conversion, both operands must be Number or both must be BigInt; mixing these types throws TypeError. A Number result can involve rounding or be NaN.

The example demonstrates storing the result, the assignment expression's value, string-to-number conversion, and BigInt multiplication. String(count) ensures that 14 is printed without console-dependent BigInt formatting.

Examples

let total = 6;
const result = (total *= 4);
console.log(total, result);

let amount = "5";
amount *= 3;
console.log(amount, typeof amount);

let count = 7n;
count *= 2n;
console.log(String(count));

Result

24 24
15 number
14

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