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