Comparison Operators
Value comparison operators that return boolean results.
== - Equal (Loose Equality)
Checks if two values are equal with type coercion.
Syntax
{"==": [value1, value2]}
Parameters
- value1 (any): First value
- value2 (any): Second value
Return Type
Boolean - true if values are equal (after type coercion)
Examples
Basic equality:
{"==": [1, 1]}           // → true
{"==": ["hello", "hello"]} // → true
{"==": [true, true]}     // → true
Type coercion:
{"==": [1, "1"]}         // → true (string coerced to number)
{"==": [0, false]}       // → true
{"==": [null, null]}     // → true
With variables:
// Data: {"age": 30, "minAge": 30}
{"==": [{"var": "age"}, {"var": "minAge"}]}
// → true
=== - Strict Equal
Checks if two values are equal without type coercion.
Syntax
{"===": [value1, value2]}
Examples
Strict equality:
{"===": [1, 1]}           // → true
{"===": [1, "1"]}         // → false (different types)
{"===": [0, false]}       // → false (different types)
!= - Not Equal
Checks if two values are not equal with type coercion.
Syntax
{"!=": [value1, value2]}
Examples
{"!=": [1, 2]}            // → true
{"!=": [1, "1"]}          // → false (coerced to same)
!== - Strict Not Equal
Checks if two values are not equal without type coercion.
Syntax
{"!==": [value1, value2]}
Examples
{"!==": [1, "1"]}         // → true (different types)
{"!==": [1, 1]}           // → false
< - Less Than
Syntax
{"<": [value1, value2]}
Examples
{"<": [5, 10]}            // → true
{"<": ["a", "b"]}         // → true (lexicographic)
<= - Less Than or Equal
Syntax
{"<=": [value1, value2]}
Examples
{"<=": [5, 10]}           // → true
{"<=": [10, 10]}          // → true
> - Greater Than
Syntax
{">": [value1, value2]}
Examples
{">": [10, 5]}            // → true
{">": [{var": "age"}, 18]} // Age check
>= - Greater Than or Equal
Syntax
{">=": [value1, value2]}
Examples
{">=": [10, 5]}           // → true
{">=": [10, 10]}          // → true
Complex Examples
Range Validation
{"and": [
  {">=": [{"var": "value"}, 10]},
  {"<=": [{"var": "value"}, 100]}
]}
Grade Calculator
{"if": [
  {">=": [{"var": "score"}, 90]}, "A",
  {"if": [
    {">=": [{"var": "score"}, 80]}, "B",
    {"if": [
      {">=": [{"var": "score"}, 70]}, "C",
      "F"
    ]}
  ]}
]}
Best Practices
- Use strict equality when type matters
- Combine comparisons for range checks
- Order matters in chained conditions
Related Operators
- Logical Operators - Combine comparisons
- if - Branch based on comparisons