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
- TypeScript
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;
tsx
const foo = 5;const bar = 10;(foo === 5) === true;(foo === bar) === false;
tsx
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
- TypeScript
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;
tsx
const foo = 5;const bar = 10;(foo !== 5) === false;(foo !== bar) === true;
tsx
const foo = 5;const bar = 10;(foo !== 5) === false;(foo !== bar) === true;