Skip to the content.

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

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

  1. Use strict equality when type matters
  2. Combine comparisons for range checks
  3. Order matters in chained conditions