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:

Operator Description Example
== Is equal to 10==30 = false
=== Identical (equal and of same type) 10==40 = false
!= Not equal to 20!=20 = true
!== Not Identical 20!==20 = false
> Greater than 30>10 = true
>= Greater than or equal to 40>=10 = true
< Less than 25<10 = false
<= Less than or equal to 25<=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)

Try it:

JS Bin on

TypeScript Tutorial

TypeScript Overview.
Typescript vs Javascript.
Typescript let vs var.
TypeScript Hello World.
Typescript Data Types.
Typescript Variable Declaration.
TypeScript operators list.
TypeScript Arithmetic Operators.
TypeScript Comparison Operators.
TypeScript Bitwise Operators.
Typescript Logical Operators.
TypeScript Assignment Operators.
Typescript Conditional Operator.
Typescript String Operator.
Typescript typeof Operator.
TypeScript control statements.
TypeScript Switch Statement.
TypeScript for loop.
TypeScript for in loop.
TypeScript while loop.
TypeScript do while loop.
Typescript for loop break.
TypeScript for loop continue.
Typescript function.
Typescript returning function.
Typescript parameterized function.
Typescript function optional parameter.
Typescript rest parameters.
Typescript default parameters.
Typescript anonymous function.
Typescript function constructor.
Typescript Arrow/Lambda function.
Typescript function overloading.
TypeScript number object.
TypeScript string object.
TypeScript boolean object.
TypeScript date object.
TypeScript math object.
TypeScript array object.
TypeScript tuples.
TypeScript union type.
TypeScript interface.
TypeScript interface inheritance.
TypeScript interface multiple inheritance.
TypeScript class.
Typescript class inheritance.
Typescript class interface.
TypeScript abstract class.
TypeScript object.
TypeScript duck typing.
TypeScript NameSpace.
TypeScript Multi-file namespaces.
TypeScript module.
TypeScript ambient module.

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki