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

JavaScript, the concept of "left-to-right" often called left-to-right evaluation or left-to-right associativity

Example 1: Basic Arithmetic Javascript  let result = 5 + 3 * 2 ; console . log (result); // Output: 11 Here’s the breakdown: The  *  (mu...

Best for you