Skip to main content Link Search Menu Expand Document (external link)

<= : Less Than or Equal Operator


On this page

Summary

Compare if the left value is less than or equal to the right value.

Syntax



Precedence

Priority level in expression evaluation (1 = highest, 10 = lowest): 6

Evaluated after: ^, *, /, %, +, -

Evaluated before: ==, !=, ??, &&, ||


Operands

Position Type Description
Left Comparable First value to compare
Right Comparable Second value to compare

Returns

Type: Boolean

true if left operand is less than or equal to right operand, false otherwise.


Examples

Low Stock Alert


  <div class="alert-warning">
    <strong>Low Stock Warning</strong>
    <p>Only  units left - reorder soon!</p>
  </div>

Data:

doc.Params["model"] = new {
    stock = 8
};

Output:

<div class="alert-warning">
  <strong>Low Stock Warning</strong>
  <p>Only 8 units left - reorder soon!</p>
</div>

Score Validation


  <p class="valid">Score: /100</p>

  <p class="error">Invalid score:  (must be ≤ 100)</p>

Capacity Check


  <span class="available"> spots available</span>

  <span class="full">Event is full</span>

Data:

doc.Params["model"] = new {
    attendees = 98,
    capacity = 100
};

Output:

<span class="available">2 spots available</span>

Date Deadline Check


  <div class="overdue">
    <strong>Overdue!</strong>
    <p>Due: </p>
  </div>

Price Range Filter


  
    <div class="product-affordable">
      <h3></h3>
      <p>$</p>
      <span class="badge">Within Budget</span>
    </div>
  

Data:

doc.Params["model"] = new {
    maxBudget = 50,
    products = new[] {
        new { name = "Basic Widget", price = 29.99m },
        new { name = "Premium Widget", price = 79.99m },
        new { name = "Standard Widget", price = 49.99m }
    }
};

Output:

<div class="product-affordable">
  <h3>Basic Widget</h3>
  <p>$29.99</p>
  <span class="badge">Within Budget</span>
</div>
<div class="product-affordable">
  <h3>Standard Widget</h3>
  <p>$49.99</p>
  <span class="badge">Within Budget</span>
</div>

Notes

  • Works with numbers, dates, and comparable types
  • Includes equality (=) unlike < operator
  • String comparison is case-sensitive and uses lexicographic ordering
  • Date comparison compares chronological order
  • Cannot compare incompatible types
  • Commonly used with `` for conditional rendering
  • Can be combined with logical operators (&&, ||)

See Also