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 + Angular-compatible version of loan amortization calculator that you can integrate into an Angular component or service

  JavaScript Version of Loan Amortization 1. Loan Calculator Function (Pure JS/TS) export function calculateLoanSchedule ( principal:...

Best for you