The JavaScript Multiplication * operator
The multiplication operator * multiplies two numbers: 4 * 3 is 12. Like the other arithmetic operators (but unlike +), it coerces string operands to numbers, so "4" * 3 is 12. The compound form *= multiplies and reassigns. For powers, use **.
Overview
* multiplies two numbers — 4 * 3 is 12, 2.5 * 2 is 5. Like subtraction and division, it always does arithmetic, coercing string operands to numbers: "4" * 3 is 12. If an operand can't be converted, the result is NaN.
It follows standard precedence: multiplication (and division) happen before addition and subtraction, so 2 + 3 * 4 is 14, not 20 — use parentheses when you want a different order. There's a compound form, *=, that multiplies and reassigns in one step (x *= 2 doubles x).
Don't confuse * with raising to a power — that's the exponentiation operator ** (2 ** 3 is 8), or Math.pow(). As with all floating-point math, results can carry tiny rounding errors, so round when displaying. And remember overflow doesn't error — a result too large becomes Infinity.
Syntax
a * b
4 * 3 // 12
"4" * 3 // 12 (string coerced)
2 + 3 * 4 // 14 (* before +)
x *= 2; // multiply and reassign
2 ** 3 // 8 (power - different operator)
Example
<pre id="out" style="font:15px ui-monospace,monospace"></pre>
<script>
const price = 19.99, qty = 3;
document.getElementById('out').textContent =
'subtotal: $' + (price * qty).toFixed(2) + '\n' +
'2 + 3 * 4 = ' + (2 + 3 * 4); // subtotal: $59.97 / 14
</script>
Best practices
Frequently asked questions
How do I multiply numbers in JavaScript?
* operator: 4 * 3 is 12. It coerces string operands to numbers.What is the difference between * and **?
Why is 2 + 3 * 4 equal to 14?
3 * 4 runs first. Use parentheses, (2 + 3) * 4, to change the order.What does *= do?
x *= 2 is shorthand for x = x * 2.