Operators TypeScript
TypeScript mainly includes the following operations:
- Arithmetic Operators
- Logical Operators
- Relational Operators
- Bitwise Operators
- Assignment Operators
- Yuan / conditional operator
- String operators
- Type Operators
Examples Figure:
Relational Operators
Relational operators for determining whether the calculation result is true or false.
Logical Operators
Logical operators for determining the logical connection between the variable or value. && (and) || (or)! (non)
Ternary operator (?)
Ternary operator has three operands, and needs to determine the Boolean expressions. This operator is primarily to determine which value should be assigned to the variable.
Test ? expr1 : expr2
- Test - the conditions specified in the statement
- expr1 - Returns true if the conditional statement Test the value is returned
- expr2 - If the condition returns false statement Test the value is returned
Type Operators
typeof is a unary operator, return data type of the operand.
var NUM = 12 is Console . log ( typeof NUM ) ; // output: number