> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript Multiplication

The multiplication operator (`*`) is a binary arithmetic operator that calculates the product of its two operands. In JavaScript, it operates on both `Number` (adhering to IEEE 754 double-precision floating-point arithmetic) and `BigInt` types.

```javascript theme={"dark"}
operand1 * operand2
```

## Type Coercion and Evaluation

If an operand is not a primitive `Number` or `BigInt`, JavaScript implicitly coerces it using the abstract `ToNumeric` operation before executing the multiplication. The `ToNumeric` operation coerces the value to a *Numeric* type, which can be either a `Number` or a `BigInt`, depending on the operand's primitive representation.

* **Objects:** JavaScript attempts to convert the object to a primitive value by calling its `valueOf()` method, followed by `toString()`. The resulting primitive is then coerced to a Numeric type. If the object resolves to a `BigInt` primitive, it evaluates as a `BigInt`.
* **Booleans:** `true` coerces to `1`, `false` coerces to `0`.
* **Strings:** Parsed as numeric values. Empty strings (`""`) coerce to `0`. Unparseable strings coerce to `NaN`.
* **Null/Undefined:** `null` coerces to `0`. `undefined` coerces to `NaN`.

```javascript theme={"dark"}
5 * "4"         // 20 (String coerced to Number)
5 * true        // 5  (Boolean coerced to 1)
5 * null        // 0  (null coerced to 0)
5 * undefined   // NaN (undefined coerced to NaN)
5 * "foo"       // NaN (Unparseable string coerced to NaN)
5 * []          // 0  (Empty array coerces to "", then to 0)
5 * [2]         // 10 (Array coerces to "2", then to 2)
2n * Object(3n) // 6n (Object coerced to BigInt primitive, not Number)
```

## IEEE 754 Floating-Point Precision Loss

Because JavaScript `Number` types are represented as 64-bit floating-point values, the `*` operator is subject to floating-point precision loss. Operations involving fractional numbers cannot always be represented exactly in binary, leading to rounding errors during multiplication.

```javascript theme={"dark"}
0.1 * 0.2       // 0.020000000000000004
```

## IEEE 754 Edge Cases

The `*` operator follows specific rules for special numeric values (`NaN`, `Infinity`, `-Infinity`, and `-0`):

* **NaN:** If either operand evaluates to `NaN`, the result is always `NaN`.
* **Infinity:** Multiplying `Infinity` by a non-zero number results in `Infinity` (or `-Infinity` depending on the sign).
* **Infinity and Zero:** Multiplying `Infinity` (or `-Infinity`) by `0` (or `-0`) evaluates to `NaN`.
* **Signed Zeros:** Multiplying two numbers with different signs where the exact mathematical result is zero evaluates to `-0`.

```javascript theme={"dark"}
NaN * 5         // NaN
Infinity * 2    // Infinity
Infinity * -2   // -Infinity
Infinity * 0    // NaN
-1 * 0          // -0
```

## BigInt Operands

The `*` operator supports `BigInt` operands, performing arbitrary-precision integer multiplication. However, JavaScript does not allow implicit coercion between `Number` and `BigInt` types during arithmetic operations. Both operands must resolve to the same numeric type.

```javascript theme={"dark"}
2n * 3n         // 6n
-5n * 4n        // -20n

// Mixing types throws a TypeError
2n * 3          // TypeError: Cannot mix BigInt and other types
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor JavaScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
