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

Advanced Angular Interview Questions with Code Examples

Advanced Angular Interview Questions with Code Examples Component Communication & State Management 1. Parent-Child Communication with ...

Best for you