Comparison Operators in JavaScript with example

Comparison operators compare two values and return a boolean result (true or false).


Example: javascript


let x = 10, y = 20;

console.log(x === y); // Strict equality (false)

console.log(x != y); // Not equal (true)

console.log(x < y); // Less than (true)

console.log(x > y); // Greater than (false)

console.log(x <= y); // Less than or equal (true)

console.log(x >= y); // Greater than or equal (false)


Explanation:


=== checks if two values are strictly equal.

!= checks if two values are not equal.

<, >, <=, >= compare values based on size.

7. Mathematical Functions

JavaScript provides built-in mathematical functions like Math.max(), Math.min(), Math.round(), etc.

No comments:

Post a Comment

Angular's new httpResource and a bonus hidden feature

  The first   release candidate   for   Angular 19.2   is out, and it includes the new experimental   httpResource . This is essentially a s...

Best for you