Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js comparison operators

Javascript Comparison Operators
== Equal to
=== Equal value and equal type
!= Not equal
!== Not equal value or not equal type
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
? Ternary operator
Comment

JavaScript Comparison Operators

Operator	Description	Example
==	Equal to: returns true if the operands are equal	x == y
!=	Not equal to: returns true if the operands are not equal	x != y
===	Strict equal to: true if the operands are equal and of the same type	x === y
!==	Strict not equal to: true if the operands are equal but of different type or not equal at all	x !== y
>	Greater than: true if left operand is greater than the right operand	x > y
>=	Greater than or equal to: true if left operand is greater than or equal to the right operand	x >= y
<	Less than: true if the left operand is less than the right operand	x < y
<=	Less than or equal to: true if the left operand is less than or equal to the right operand	x <= y
Comment

string comparison javascript

string1.localeCompare(string2);
//returns postivie number if string1>string2
//returns negative number if string1<string2
//returns 0 if they are equivalent
Comment

javascript string compare

employees.sort((a, b) => {
    let fa = a.firstName.toLowerCase(),
        fb = b.firstName.toLowerCase();

    if (fa < fb) {
        return -1;
    }
    if (fa > fb) {
        return 1;
    }
    return 0;
});
Code language: JavaScript (javascript)
Comment

Javascript comparison

const num1 = 450;
const num2 = 350;
const num3 = 1000;

if (num1 > num2 && num1 > num3) {
    console.log("num1 is bigger then num2 and num3");
} else if (num2 > num1 && num2 > num3) {
    console.log("num2 is bigger num1 and num3");
} else {
    console.log("num3 is bigger then num1 and num2");
}
//Output: num3 is bigger then num1 and num2
Comment

PREVIOUS NEXT
Code Example
Javascript :: reverse () method to reverse the array 
Javascript :: javascript object as key 
Javascript :: Sequelize using javascript 
Javascript :: samoglasnici-vowels 
Javascript :: componentDidmount event on fonctional component 
Javascript :: comments in jsx 
Javascript :: + javascript 
Javascript :: Return with an "IF" Statement 
Javascript :: pass array as function argument javascript 
Javascript :: project to do with javascript 
Javascript :: javascript join 2 variables into string 
Javascript :: remix js 
Javascript :: react live chat widget 
Javascript :: javascript call 
Javascript :: how to console log in react native 
Javascript :: js append html in div after 
Javascript :: javascript meme 
Javascript :: difference between =, == and === in javascript 
Javascript :: javascript null 
Javascript :: get body 
Javascript :: reactjs events list 
Javascript :: express api 
Javascript :: how to call function with only selected arguments in javascript 
Javascript :: query relation data in mongoose 
Javascript :: angular navbar is overlaying content 
Javascript :: using the for of loop in pure javascript to populate data into HTML 
Javascript :: immutablejs update use 
Javascript :: boxcolliion code javascript 
Javascript :: naming a function in javascript 
Javascript :: how to store and extract local storage 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =