JavaScript Arithmetic # 03

Ishika IshaniIshika Ishani
2 min read

An arithmetic operator accepts numerical values as operands and returns a single numerical value. The numerical values can be literals or variables.
In JavaScript following are the arithmetic operators :

A typical arithmetic operation operates on two numbers, which can be literals, variables or expressions.
These numbers in an arithmetic operation are called operands. And the operation that needs to be performed between the two operands is defined by an operator

Let us discuss the arithmetic operators with example.

  1. Addition: The addition operator + adds numbers.

  2. Subtraction: The subtraction operator - subtracts numbers.

  1. Multiplication: The multiplication operator * multiplies numbers.

  1. Division: The division operator / divides numbers.

  1. Modulus: The modulus operator % returns the division remainder.

  1. Exponentiation: The exponentiation operator ** raises the first operand to the power of the second operand.

  1. Increment: The increment operator ++ increments numbers.

  1. Decrement: The decrement operator -- decrements numbers.

While doing operations of expressions in JavaScript, the focus should be given to Operator Precedence.

Operator precedence describes the order in which operations are performed in an arithmetic expression.

  1. When using parentheses, the operations inside the parentheses are computed first.

  2. Multiplication * and division / have higher precedence than addition + and subtraction - .

  3. When many operations have the same precedence (like addition and subtraction or multiplication and division), they are computed from left to right.

Click for Operator Precedence Table

In the next blog, we will discuss Basic Math in JavaScript.
If you liked this article, consider following me on Hashnode for my latest publications.

20
Subscribe to my newsletter

Read articles from Ishika Ishani directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ishika Ishani
Ishika Ishani

I am a versatile developer skilled in web development and data science. My expertise includes HTML, CSS, JavaScript, TypeScript, React, Python, Django, Machine Learning, and Data Analysis. I am currently expanding my knowledge in Java and its applications in software development and data science. My diverse skill set enables me to create dynamic web applications and extract meaningful insights from data, driving innovative solutions.