JavaScript Arithmetic Operators

You are Here:

JavaScript Arithmetic Operators

The arithmetic operators perform arithmetic operations on numbers (either literals or variables) as their operands and return a single numerical value. The following are the list of arithmetic operators available in JavaScript.

Addition

In the following example, we will add the two given numbers (50, 45).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 50; var num2 = 45; var result = num1 + num2; document.write(result); </script> </body> </html>

JavaScript Arithmetic Operators

The following are the list of arithmetic operators available in JavaScript.

OperatorExplanationOperationResult
+Addition50 + 4590
-Subtraction50 - 455
*Multiplication5 * 210
/Division7 / 23
**Exponentiation5 ** 225
%Remainder
(Modulus)
7 % 21
++Increment++56
--Decrement--54

Subtraction

In the following example, we will subtract the two numbers (50 and 45).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 50; var num2 = 45; var result = num1 - num2; document.write(result); </script> </body> </html>

Multiplication

In the following example, we will multiply the two given numbers (5 and 2).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 5; var num2 = 2; var result = num1 * num2; document.write(result); </script> </body> </html>

Exponentiation

In the following example, we will perform the operation of raising one quantity to the power of another (52).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num = 5; var result = num ** 2; document.write(result); </script> </body> </html>

Division

In the following example, we will divide the two given numbers (7 by 2).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num = 7; var result = num / 2; document.write(result); </script> </body> </html>

Modulus

In the following example, we will find the remainder of the two given number (7 and 2) when dividied.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num = 7; var result = num % 2; document.write(result); </script> </body> </html>

Increment

In the following example, we will increment the given number (3).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num = 3; var result = ++num; document.write(result); </script> </body> </html>

Decrement

In the following example, we will decrement the given number (3).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num = 3; var result = --num; document.write(result); </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author