JAVASCRIPT Tutorial
Relational operators are used to compare two values and return a boolean (true or false) value. They help you determine the relationship between two values.
Operator | Description |
---|---|
== |
Checks for equality (value comparison) |
!= |
Checks for inequality (value comparison) |
< |
Checks if the left operand is less than the right operand (value comparison) |
> |
Checks if the left operand is greater than the right operand (value comparison) |
<= |
Checks if the left operand is less than or equal to the right operand (value comparison) |
>= |
Checks if the left operand is greater than or equal to the right operand (value comparison) |
typeof
and instanceof
)typeof
: Returns the type of a value (e.g., "string", "number").instanceof
: Checks if an object belongs to a specific class or constructor.// Value Comparison
console.log(10 == 10); // true
console.log(10 != 10); // false
// Type Checking and Property Check
console.log(typeof "Hello"); // string
console.log("Hello" instanceof String); // true