Skip to main content

Comparison Operators

Used to compare values of all types with each other.

info

Numeric types (integer and float) can be compared freely even though they have different primitive types.

Equal (==)

This operation returns true if two values are the same and false otherwise.

knot
const foo = 5;
const bar = 10;
(foo == 5) == true;
(foo == bar) == false;
knot
const foo = 5;
const bar = 10;
(foo == 5) == true;
(foo == bar) == false;

Not Equal (!=)

This operation returns true if two values are not the same and false otherwise.

knot
const foo = 5;
const bar = 10;
(foo != 5) == false;
(foo != bar) == true;
knot
const foo = 5;
const bar = 10;
(foo != 5) == false;
(foo != bar) == true;