What is operator
Operator is an object in computer programming used to evaluate an value based on the operands defined
The operators are categorized into various groups
1 Arithmetic Operator
2 Comparison Operator
3 Bit-Wise Operator
4 Logical Operator
5 Assignment Operator
6 Special Operator
Arithmetic Operator
+ Addition
- Subtraction
* Multiplication
/ Division
% Modules(Reminder)
++ (Increment)
-- ( Decrement)
2 Comparison Operator
== Is Equal to (10==20)
=== Identical Equal and of same Type (10===20)
!= Not Equal to
!== Not Identical
> Greater than
< Less than
3 BitWise Operator
& --Bitwise And
| Bit Wise Or
^ Bit wise XOR
<< Bit wise Left Shift
>> Bitwise Right Shift
Logical Operator
&&--> Logical And
||--- > Logical OR
! Logical Not
Assignment Operator
= Assign
+= Add And Assign
- = Substract and Assign
*= Multiply and Assign
/ = Divide and Assign
%= Module and Assign
Special Operators in Type Script
Ternary Operator ( ? : )
Syntax
let pin: number=4040;
console.log(pin==4040 ? "valid" : "invalid" )
Delete operator
It is used to delete a property from any specified object.
let product : any ={
Name : 'TV',
price : 333
}
delete product.price //valid
console.log("price= " + product.price); //undefined
Note: You cannot delete read only properties
delete Math.PI //Invalid
In operator
It is used to verify whether the given property is available in an object .It returns true if found
Syntax
console.log("price" in products) //true -- if price is found
In is used to verify the properties
OF operator
It is an special operator used to verify the values in an object. It returns boolean true if they the values are in collection.
Ex:
let cities: string[] =["Delhi" , "Hyd" ]
for( var city of cities) {
console.log(city)
}
typeof operator
It is an special operator that is used to identity and return data type of a property in an object.
Example
Output:
No comments:
Post a Comment
Thank you for visiting my blog