Skip to main content
The *= (multiplication assignment) operator multiplies the value of the left operand by the value of the right operand and assigns the computed product to the left operand.

Technical Mechanics

  1. Single Evaluation: The reference to the left operand is evaluated exactly once. This is a critical distinction from the expanded form leftOperand = leftOperand * rightOperand, which evaluates the left side twice. If the left operand contains an expression with side effects (such as arr[i++]), the *= operator ensures the side effect executes only once.
  2. Mutability Requirement: The left operand must be a valid, mutable l-value, such as a variable declared with let or var, or a writable object property. Attempting to use *= on a const declaration will result in a compiler error.
  3. Return Value: The operation returns the newly assigned value of the left operand, allowing the assignment to be chained or embedded within larger expressions.

TypeScript Type Constraints

TypeScript enforces strict compile-time type checking on both operands involved in the *= operation:
  • Permitted Types: Both operands must resolve to type number, bigint, any, or an enum type.
  • Type Homogeneity: You cannot mix number and bigint operands. Doing so violates both TypeScript’s static type rules and JavaScript’s runtime rules.
  • Assignment Compatibility: The resulting product must be assignable back to the declared type of the left operand.

Syntax Visualization

Valid Operations:
TypeScript Compiler Errors:
Tired of Poor TypeScript Skills? Fix That With Deep Grasping!Learn More