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

Comparison operators in JavaScript

// equal operator
console.log(2 == 2); // true
console.log(2 == '2'); // true

// not equal operator
console.log(3 != 2); // true
console.log('hello' != 'Hello'); // true

// strict equal operator
console.log(2 === 2); // true
console.log(2 === '2'); // false

// strict not equal operator
console.log(2 !== '2'); // true
console.log(2 !== 2); // false
Comment

JavaScript Comparison and Logical Operators

if (age < 18) text = "Too young to buy alcohol";
Comment

what are the comparison operators in javascript

<, >, <=, >=, ==, ===, !=, !==
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript repeat function 
Javascript :: check a letter in astring js 
Javascript :: jquery dialog modal on modal 
Javascript :: inline styling react 
Javascript :: how to lose overflow in js without hidden 
Javascript :: Use jsx extension react-native 
Javascript :: asynch action redux 
Javascript :: alert library css and js 
Javascript :: drupal 8 webform insert node twig value 
Javascript :: angular reference element 
Javascript :: javscript call 
Javascript :: jQuery exists function 
Javascript :: documentelement javascript 
Javascript :: mongoose node js 
Javascript :: javascript bind multiple arguments 
Javascript :: react map array 
Javascript :: how to delete an exact element of array 
Javascript :: what is react reveal 
Javascript :: findindex method javascript 
Javascript :: error handling in node.js 
Javascript :: creating javascript class 
Javascript :: difference between single quotes and double quotes in javascript 
Javascript :: javascript object methods 
Javascript :: nodejs temp file 
Javascript :: blockchain javascript 
Javascript :: Check Object Is Instance Of Class 
Javascript :: loading screen fivem js 
Javascript :: string to code javascript 
Javascript :: chai js 
Javascript :: react native svg size 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =