HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / TypeScript / TypeScript Arithmetic Operators

TypeScript Arithmetic Operators

An operator is a symbol that represents a specific action. An arithmetic operator can be used with one or more than values to produce a single value.

In typescript, we can perform arithmetic operations using below given 10 operators.

Arithmetic operators

OperatorNameDescription and Example
x + yAddition Adds two operands.

			let x = 10;
			let y = 20;

			let z = x + y;

			console.log( z );	//Output 30
			
x - ySubtraction Subtracts two operands.

			let x = 10;
			let y = 20;

			let z = x - y;

			console.log( z );	//Output -10
			
-xNegation Negate the sign. Opposite of number.

			let x = 10;

			let z = -x;

			console.log( z );	//Output -10
			
x * yMultiplication Negate the sign. Opposite of number.

			let x = 10;
			let y = 20;

			let z = x * y;

			console.log( z );	//Output 200
			
x ** yExponentiation Multiplies the first operand by itself a number of times which is indicated by the second operand.

			let x = 10;
			let y = 20;

			let z = x ** y;

			console.log( z );	//Output 100000000000000000000 or 1e+20
			
x / yDivision Divides the numerator by the denominator.

			let x = 10;
			let y = 20;

			let z = x / y;

			console.log( z );	//Output 2
			
x % yModulus Returns the remainder after an integer division.

			let x = 10;
			let y = 20;

			let z = x % y;

			console.log( z );	//Output 10
			
x++Increment Increases an integer value by one.

			let x = 10;

			x++;

			console.log( x );	//Output 11
			
x--Decrement Decreases an integer value by one.

			let x = 10;

			x--;

			console.log( x );	//Output 9
			

Above are the arithmetic operators used in typescript.

Drop me your questions in comments section.

Happy Learning !!

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Reddit

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Comments are closed on this article!

Search Tutorials

TypeScript Tutorial

  • TypeScript – Introduction
  • TypeScript – Types
  • TypeScript – Union Types
  • TypeScript – String Literal Types
  • TypeScript – var, let and const
  • TypeScript – Template Strings
  • TypeScript – Arithmetic Operators
  • TypeScript – Logical Operators
  • TypeScript – Comparison Operators
  • TypeScript – for Loop
  • TypeScript – Spread Operator
  • TypeScript – Arrays
  • TypeScript – Enums
  • TypeScript – Map
  • TypeScript – Set
  • TypeScript – Functions
  • TypeScript – Function Overloading
  • TypeScript – Transpiler
  • TypeScript – Truthy and falsy
  • TypeScript – == vs ===
  • TypeScript – undefined vs null
  • TypeScript – Variable Hoisting
  • TypeScript – tsconfig.json

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Java 15 New Features
  • Sealed Classes and Interfaces
  • EdDSA (Ed25519 / Ed448)