☰ See All Chapters |
TypeScript boolean type
boolean is a predefined type. A boolean variable can be set to either true or false. The following examples demonstrate how boolean variables can be declared and initialized:
const a: boolean = 4 > 3;
const hello:string = "hello"; const hi:string = "hi"; const b: boolean = hello === hi;
const c: boolean = ((4 > 3) && b);
|
Variables equality check
JavaScript/TypeScript provides two operators for testing equality: == and ===.
== Compares only value. Returns true if operators have the same value.
=== Compares both value and type. Returns true if operators have the same value and the same type.
All Chapters