> ## 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 Less Than

The less than (`<`) operator is a binary relational operator that evaluates whether the left operand is strictly smaller in mathematical or lexicographical value than the right operand, returning a boolean (`true` or `false`).

```javascript theme={"dark"}
leftOperand < rightOperand
```

## Evaluation Algorithm (Abstract Relational Comparison)

When the JavaScript engine evaluates `x < y`, it executes the Abstract Relational Comparison algorithm. This dictates how different data types are coerced and compared:

1. **Primitive Coercion (`ToPrimitive`)**: The engine converts both operands to primitive values. If an operand is an object, it invokes its `[Symbol.toPrimitive]()`, `valueOf()`, or `toString()` methods, with a hint of `Number`.
2. **String vs. String**: If *both* resulting primitives are strings, the operator performs a lexicographical comparison. It compares the strings character by character from left to right, based on their 16-bit unsigned integer UTF-16 code unit values.
3. **Numeric Conversion (`ToNumeric`)**: If *at least one* of the resulting primitives is not a string, the engine coerces both operands to numeric values (either `Number` or `BigInt`) before comparing.

## Type Coercion Rules and Edge Cases

* **`NaN` (Not-a-Number)**: If either operand is `NaN`, or coerces to `NaN` (e.g., `undefined`, unparseable strings, or arrays with multiple elements), the operator always returns `false`.
* **Booleans**: `true` coerces to `1` and `false` coerces to `0`.
* **Nullish Values**: `null` coerces to `0`. `undefined` coerces to `NaN`.
* **Zeroes**: `+0` and `-0` are considered mathematically equal, so `-0 < +0` evaluates to `false`.
* **BigInt vs Number**: When comparing a `BigInt` to a `Number`, JavaScript compares their exact mathematical values without implicit conversion, preventing precision loss.

## Syntax Visualization

**Numeric Comparison:**

```javascript theme={"dark"}
5 < 10;       // true
10 < 10;      // false (strictly less than, not equal)
-0 < +0;      // false
```

**String Comparison (UTF-16 Lexicographical):**

```javascript theme={"dark"}
"apple" < "banana"; // true ('a' is 0x0061, 'b' is 0x0062)
"Zebra" < "apple";  // true ('Z' is 0x005A, 'a' is 0x0061 - uppercase precedes lowercase)
"10" < "2";         // true ('1' is 0x0031, '2' is 0x0032)
```

**Mixed Type Comparison (Implicit Numeric Coercion):**

```javascript theme={"dark"}
"10" < 20;    // true  (String "10" coerces to Number 10)
false < 1;    // true  (Boolean false coerces to Number 0)
null < 1;     // true  (null coerces to Number 0)
```

**NaN and Undefined:**

```javascript theme={"dark"}
NaN < 5;        // false
5 < NaN;        // false
undefined < 5;  // false (undefined coerces to NaN)
```

**Object Coercion:**

```javascript theme={"dark"}
[2] < 3;        // true  ([2] coerces to "2", then to Number 2)
[2, 3] < 4;     // false ([2, 3] coerces to "2,3", then to NaN)
```

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