> ## 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 Unary Plus

The `+` operator in JavaScript is a polymorphic operator that performs either numeric addition or string concatenation depending on the types of its evaluated operands. It also functions as a unary operator to explicitly coerce a single operand into a numeric value.

## Syntax

```javascript theme={"dark"}
// Binary Operator
LeftOperand + RightOperand

// Unary Operator
+Operand
```

## Binary Operator Mechanics

When used as a binary operator, the JavaScript engine follows a strict evaluation algorithm defined by the ECMAScript specification to determine whether to add or concatenate. The engine resolves the operation through the following sequence:

1. **Primitive Conversion:** The engine applies the internal `ToPrimitive()` abstract operation to both operands. Objects and Arrays are converted to their primitive values (typically by invoking their internal `valueOf()` or `toString()` methods).
2. **Type Evaluation:**
   * If either of the resulting primitive values is a **String**, the engine applies the `ToString()` abstract operation to both operands and performs **string concatenation**.
   * If neither primitive value is a String, the engine applies the `ToNumeric()` abstract operation to both operands and performs **numeric addition**. If the operands resolve to different numeric types (e.g., mixing `Number` and `BigInt`), the engine throws a `TypeError`.
   * If either operand is a **Symbol**, the engine throws a `TypeError` as Symbols cannot be implicitly coerced to strings or numbers.

### Coercion Behavior

```javascript theme={"dark"}
// Numeric Addition (neither operand resolves to a string)
1 + 2               // 3
1 + true            // 2 (true coerces to 1)
1 + null            // 1 (null coerces to 0)
1 + undefined       // NaN (undefined coerces to NaN)

// String Concatenation (at least one operand resolves to a string)
"1" + 2             // "12"
"System" + true     // "Systemtrue"
"" + null           // "null"

// Complex Type Coercion (ToPrimitive evaluation)
[1, 2] + [3, 4]     // "1,23,4" (Arrays coerce to strings "1,2" and "3,4")
({} + [])           // "[object Object]" (Expression context forces Object coercion)

// BigInt and Symbol Exceptions
10n + 20n           // 30n
10n + 5             // TypeError: Cannot mix BigInt and other types
Symbol("a") + "b"   // TypeError: Cannot convert a Symbol value to a string
```

## Unary Operator Mechanics

When used as a prefix to a single operand, the unary `+` operator directly triggers the internal `ToNumber()` abstract operation. It bypasses string concatenation logic entirely and attempts to parse the operand into an IEEE 754 double-precision float. Because the operation strictly enforces `ToNumber()`, applying the unary `+` to a `BigInt` or `Symbol` will throw a `TypeError`.

### Unary Coercion Behavior

```javascript theme={"dark"}
+"42"               // 42 (String to Number)
+"0xFF"             // 255 (Hexadecimal string to Number)
+true               // 1 (Boolean to Number)
+false              // 0
+null               // 0
+undefined          // NaN
+""                 // 0 (Empty string to Number)
+new Date()         // 1697040000000 (Date object to epoch timestamp)
+{}                 // NaN (Object to Number)

// BigInt and Symbol Exceptions
+10n                // TypeError: Cannot convert a BigInt value to a number
+Symbol("a")        // TypeError: Cannot convert a Symbol value to a number
```

<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>
