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

The simple assignment operator (`=`) assigns a value to a variable, property, or destructuring pattern. It modifies the memory binding of the Left-Hand Side (LHS) expression to point to the evaluated Right-Hand Side (RHS) value.

```javascript theme={"dark"}
LeftHandSideExpression = AssignmentExpression
```

## Evaluation Mechanics

According to the ECMAScript specification, when the JavaScript engine encounters the `=` operator, it performs the following sequence of operations:

1. **LHS Resolution:** The engine first evaluates the `LeftHandSideExpression` to resolve its memory reference (an *l-value*).
2. **RHS Evaluation:** The engine then fully evaluates the `AssignmentExpression` on the right side to produce a value.
3. **Value Binding:** The evaluated RHS value is stored in the memory location dictated by the LHS reference.
4. **Return:** The operation resolves to the assigned RHS value, making the assignment itself an expression.

## Return Value

Because the assignment operation returns the evaluated RHS value, it can be embedded within larger expressions.

```javascript theme={"dark"}
let y;
// The expression (y = 5) evaluates to 5, which is then added to 10
let x = 10 + (y = 5); 
```

## Associativity

The `=` operator has **right-to-left associativity**. When multiple assignment operators appear in the same expression, the JavaScript engine resolves the assignments from right to left.

```javascript theme={"dark"}
let a, b, c;
// Evaluated as: a = (b = (c = 5))
a = b = c = 5;
```

In this sequence, the reference for `a`, `b`, and `c` are resolved left-to-right. Then, `c = 5` is executed, returning `5`. That return value is assigned to `b`, which returns `5`, which is finally assigned to `a`.

## Left-Hand Side Constraints

The `LeftHandSideExpression` must resolve to a valid reference (a variable, object property, or array element) or a valid destructuring assignment pattern.

* **Invalid Reference:** If the LHS is an unresolvable reference or a primitive value, a `SyntaxError` or `ReferenceError` is thrown.

```javascript theme={"dark"}
// SyntaxError: Invalid left-hand side in assignment
5 = x; 
```

* **Constant Reassignment:** If the LHS is a reference bound via the `const` declaration, the engine throws a `TypeError` at runtime, as the binding is immutable.

```javascript theme={"dark"}
const PI = 3.14;
// TypeError: Assignment to constant variable.
PI = 3.14159; 
```

* **Destructuring:** The LHS can be a complex pattern, allowing the `=` operator to unpack values from arrays or properties from objects into distinct variables.

```javascript theme={"dark"}
let a, b, x, y;

[a, b] = [1, 2];
({x, y} = {x: 10, y: 20});
```

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