Easy learning with example program codes

TypeScript Arithmetic Operators Tutorial

TypeScript Arithmetic Operators:

Arithmetic operators are used to perform arithmetic operations.

TypeScript Arithmetic Operators List:

Operator Description Example
+ Addition 30+20 = 50
Subtraction 30-10 = 20
* Multiplication 10*10 = 100
/ Division 50/10 = 5
% Modulus (Remainder) 50%7 = 1
++ Increment var a=10; a++; Result into a = 11
Decrement var a=10; a–; Result into a = 9

TypeScript Arithmetic Operators Example:

var num1:number = 20;
var num2:number = 4;
var result:number = 0;
result = num1 + num2;
console.log("Sum: "+result); 
result = num1 - num2; 
console.log("Difference: "+result);
result = num1*num2;
console.log("Product: "+result);
result = num1/num2;
console.log("Quotient: "+result);
result = num1%num2;
console.log("Remainder: "+result);
console.log("Value of num1 after increment: "+num1);
console.log("Value of num2 after decrement: "+num2);

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