|| : Logical OR Operator
On this page
Summary
Combine two boolean expressions. Returns true if at least one operand is true.
Syntax
Precedence
Priority level in expression evaluation (1 = highest, 10 = lowest): 10 (lowest)
Evaluated after: All other operators
Operands
| Position | Type | Description |
|---|---|---|
| Left | Boolean | First condition to evaluate |
| Right | Boolean | Second condition to evaluate |
Returns
Type: Boolean
true if either operand is true, false only if both are false.
Truth Table
| Left | Right | Result |
|---|---|---|
| true | true | true |
| true | false | true |
| false | true | true |
| false | false | false |
Examples
Administrative Access
Data:
doc.Params["model"] = new {
isAdmin = false,
isModerator = true
};
Output:
<div class="admin-panel">
<h2>Administration</h2>
<p>Access Level: Moderator</p>
</div>
Multiple Status Check
Data:
doc.Params["model"] = new {
status = "shipped"
};
Output:
<div class="order-completed">
<p>✓ Order in transit or completed</p>
<p>Status: shipped</p>
</div>
Weekend Detector
Alert Conditions
Data:
doc.Params["model"] = new {
items = new[] {
new { name = "Item A", stock = 5, expirationDays = 60 },
new { name = "Item B", stock = 50, expirationDays = 15 },
new { name = "Item C", stock = 8, expirationDays = 10 }
}
};
Output:
<div class="alert-warning">
<strong>Item A</strong>
<p>⚠ Low stock: 5 units</p>
</div>
<div class="alert-warning">
<strong>Item B</strong>
<p>⚠ Expiring soon: 15 days</p>
</div>
<div class="alert-warning">
<strong>Item C</strong>
<p>⚠ Low stock: 8 units</p>
<p>⚠ Expiring soon: 10 days</p>
</div>
Role-Based Display
Priority Orders
Notes
- Returns true if either or both conditions are true
- Uses short-circuit evaluation: if first condition is true, second is not evaluated
- Can chain multiple OR conditions:
a || b || c - Has lowest precedence - use parentheses for complex expressions:
(a || b) && c - Commonly used for checking multiple acceptable values
- Opposite of AND (
&&) operator logic - Note:
!(NOT) operator is not supported - use!=instead