> ## 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 Loose Inequality

The loose inequality operator (`!=`) evaluates whether two operands are not equal, returning a boolean result. Unlike the strict inequality operator (`!==`), it performs automatic type coercion via the Abstract Equality Comparison algorithm if the operands are of different data types before making the comparison. It is the exact logical negation of the loose equality operator (`==`).

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

## Evaluation Mechanics

When evaluating `a != b`, the JavaScript engine applies the following rules based on the types of the operands:

1. **Identical Types:** If both operands are of the same type, no coercion occurs. The operator compares their values directly.
2. **NaN:** If either or both operands are `NaN`, the operator always returns `true`. By specification, `NaN` is never equal to any value, including itself.
3. **Null and Undefined:** `null` and `undefined` are considered loosely equal to each other. Therefore, `null != undefined` evaluates to `false`. They are not loosely equal to any other value.
4. **Number, String, and BigInt:** If one operand is a String and the other is a Number or BigInt, the engine attempts to parse the String into a numeric value before comparing. If comparing a Number and a BigInt directly, they are compared by their mathematical value without strict type matching.
5. **Booleans:** If either operand is a Boolean, it is coerced into a Number (`true` becomes `1`, `false` becomes `0`) before comparison.
6. **Objects and Primitives:** If one operand is an Object and the other is a primitive (String, Number, BigInt, or Symbol), the Object is converted to a primitive value using its internal `[Symbol.toPrimitive]()`, `valueOf()`, or `toString()` methods before the comparison proceeds.

## Syntax and Coercion Visualization

```javascript theme={"dark"}
// 1. Identical Types & NaN
10 != 20;                // true
"test" != "test";        // false
NaN != NaN;              // true  (NaN is never equal to anything)

// 2. Null and Undefined
null != undefined;       // false (They are loosely equal)
null != 0;               // true  (Null does not coerce to 0 in equality checks)

// 3. Number, String, and BigInt Coercion
5 != "5";                // false ("5" is coerced to Number 5)
1n != 1;                 // false (Compared by mathematical value)
10n != "10";             // false ("10" is coerced to BigInt 10n)
0 != "";                 // false ("" is coerced to Number 0)

// 4. Boolean Coercion
0 != false;              // false (false is coerced to 0)
1 != true;               // false (true is coerced to 1)
2 != true;               // true  (true is coerced to 1; 2 != 1)

// 5. Object to Primitive Coercion
[1] != 1;                // false ([1] toString() becomes "1", then Number 1)
[""] != 0;               // false ([""] toString() becomes "", then Number 0)
[1, 2] != "1,2";         // false ([1, 2] toString() becomes "1,2")
```

## Memory Reference Comparison

When both operands are Objects (including Arrays and Functions), the `!=` operator does not compare their structural content or properties. Instead, it compares their references in memory. It will only return `false` if both operands point to the exact same object instance.

```javascript theme={"dark"}
const objA = { id: 1 };
const objB = { id: 1 };
const objC = objA;

objA != objB; // true  (Different memory references)
objA != objC; // false (Same memory reference)
```

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