Easy learning with example program codes

typescript comparison operators tutorial

TypeScript Comparison Operators:

TypeScript comparison operators are used to compare the two operands.

TypeScript Comparison Operators List:

==Is equal to10==30 = false
===Identical (equal and of same type)10==40 = false
!=Not equal to20!=20 = true
!==Not Identical20!==20 = false
>Greater than30>10 = true
>=Greater than or equal to40>=10 = true
<Less than25<10 = false
<=Less than or equal to25<=10 = false

TypeScript Comparison Operators Example:

var num1:number = 15;
var num2:number = 17;
console.log("Value of num1: "+num1); 
console.log("Value of num2 :"+num2);
var result = num1>num2 
console.log("num1 greater than num2: "+result)
result = num1<num2 
console.log("num1 lesser than num2: "+result)  
result = num1>=num2 
console.log("num1 greater than or equal to  num2: "+result)
result = num1<=num2
console.log("num1 lesser than or equal to num2: "+result)  
result = num1==num2 
console.log("num1 is equal to num2: "+result)  
result = num1!=num2  
console.log("num1 is not equal to num2: "+result)


Please follow and like us:

Copyright © 2020 CodesJava Protection Status