Free Masterclass on Mar 21
Beginner AI Workshop: Build an AI Agent & Start Your AI Career
Imagine you are a web developer building a website for an online store. You want to create a feature that calculates the total price of items in the shopping cart. To do this, you need to use arithmetic operators in JavaScript. You start by adding the price of each item in the cart using the addition operator (+), and then multiply the total by the sales tax using the multiplication operator (*). Finally, you display the total price to the user using the console.log() method. As you work on this feature, you realize the importance of arithmetic operators in many real-life.
Arithmetic operators are the fundamental mathematical operators used in programming to carry out calculations on numerical data. In JavaScript, arithmetic operators can be utilized to perform addition, subtraction, multiplication, division, and modulo operations. These operations can be leveraged to solve sophisticated mathematical problems, manipulate data, and build interactive web applications.
JavaScript Arithmetic Operators
There are six arithmetic operators in JavaScript, which are:
The addition operator (+) is used to add two or more values in JavaScript. For example:
Loading...
In this example, we add two variables a and b using the addition operator (+) and assign the result to a new variable c. The console.log() method is used to display the result on the console.
The subtraction operator (-) is used to subtract one value from another value in JavaScript. For example:
Loading...
In the example above, we are subtracting the value of b from a using the subtraction operator (-) and assigning the result to a new variable c.
The multiplication operator (*) is used to multiply two or more values in JavaScript. For example:
Loading...
In the example above, we are multiplying two variables a and b using the multiplication operator (*) and assigning the result to a new variable c.
The division operator (/) is used to divide one value by another value in JavaScript. For example:
Loading...
In the example above, we are dividing the value of a by b using the division operator (/) and assigning the result to a new variable c.
The modulus operator (%) is used to find the remainder of the division of one value by another value in JavaScript. For example:
Loading...
In the example above, we are finding the remainder of the division of a by b using the modulus operator (%) and assigning the result to a new variable c.
The exponentiation operator () is used to raise one value to the power of another value in JavaScript. For example:
Loading...
In the example above, we are raising the value of a to the power of b using the exponentiation operator () and assigning the result to a new variable c.
JavaScript also provides two special operators, the increment (++) operator and the decrement (--) operator. These are unary operators that can be used to increase or decrease the value of a variable by 1.
Increment Operator
The increment operator (++) is used to increase the value of a variable by 1. For example:
Loading...
In the example above, the value of variable a is increased by 1 using the increment operator (++).
Decrement Operator
The decrement operator (--) is used to decrease the value of a variable by 1. For example:
Loading...
In the example above, the value of variable a is decreased by 1 using the decrement operator (--).
Loading...
This ensures that the addition operation is performed first before the multiplication operation.
In JavaScript, arithmetic operators are essential tools for performing mathematical calculations and manipulating numerical data. By understanding these operators and how they work, developers can create powerful and interactive web applications, analyze complex data sets, and automate a wide range of tasks.
Top Tutorials

NodeJS
In this comprehensive Node JS tutorial, the fundamentals are thoroughly covered, preparing learners to create scalable and high-performance web applications. The development environment setup, module usage, asynchronous programming implementation, and integration with databases and external services are all explored. By harnessing the capabilities of server-side JavaScript, web development proficiency can be significantly enhanced.

HTML
In this HTML5 tutorial, the learner explores the latest features and enhancements of the markup language. They are guided through semantic elements, multimedia integration, and form improvements. The tutorial emphasizes practical examples to build a solid foundation in HTML5.

React Fundamentals
Learn React with the best React JS tutorial and master how to build dynamic, user-friendly web applications using the powerful JavaScript library. Start today!
All Courses (6)
Master's Degree (2)
Fellowship (2)
Certifications (2)