In JavaScript, there are several mathematical operators available that allow you to perform various arithmetic operations. These operators are fundamental tools for working with variables and performing calculations in JavaScript. Understanding these operators is essential for writing effective and efficient JavaScript code.
1. Addition Operator (+): The addition operator is used to add two values together. It can be used with both numbers and strings. When used with numbers, it performs the addition operation. When used with strings, it concatenates the two strings together.
Example:
javascript let a = 5; let b = 10; let result = a + b; // 15 let str1 = "Hello"; let str2 = "World"; let message = str1 + " " + str2; // "Hello World"
2. Subtraction Operator (-): The subtraction operator is used to subtract one value from another. It is primarily used with numbers to perform the subtraction operation.
Example:
javascript let a = 10; let b = 5; let result = a - b; // 5
3. Multiplication Operator (*): The multiplication operator is used to multiply two values together. It is primarily used with numbers to perform the multiplication operation.
Example:
javascript let a = 5; let b = 10; let result = a * b; // 50
4. Division Operator (/): The division operator is used to divide one value by another. It is primarily used with numbers to perform the division operation.
Example:
javascript let a = 10; let b = 2; let result = a / b; // 5
5. Modulus Operator (%): The modulus operator is used to find the remainder after dividing one value by another. It is primarily used with numbers.
Example:
javascript let a = 10; let b = 3; let result = a % b; // 1
6. Exponentiation Operator (**): The exponentiation operator is used to raise a base number to the power of an exponent. It is primarily used with numbers.
Example:
javascript let a = 2; let b = 3; let result = a ** b; // 8
These are the basic mathematical operators available in JavaScript. Understanding how to use them correctly is important for performing calculations and manipulating variables in JavaScript.
Other recent questions and answers regarding Examination review:
- What are the basic data types available in JavaScript?
- How can we output the result of a calculation in JavaScript?
- What is the order of execution for mathematical operations in JavaScript?
- How can we assign a value to a variable in JavaScript?

