In JavaScript, there are several mathematical operators available for performing operations on variables. These operators allow you to perform arithmetic calculations, comparisons, and other mathematical operations. Understanding these operators is essential for basic programming in JavaScript, particularly when declaring and defining variables.
1. Addition Operator (+):
The addition operator is represented by the symbol "+". It is used to add two or more values together. When used with numeric values, it performs addition. When used with strings, it concatenates them.
Example:
let a = 5; let b = 10; let result = a + b; console.log(result); // Output: 15 let str1 = "Hello"; let str2 = " World!"; let message = str1 + str2; console.log(message); // Output: Hello World!
2. Subtraction Operator (-):
The subtraction operator is represented by the symbol "-". It is used to subtract one value from another.
Example:
let a = 10; let b = 5; let result = a - b; console.log(result); // Output: 5
3. Multiplication Operator (*):
The multiplication operator is represented by the symbol "*". It is used to multiply two or more values together.
Example:
let a = 2; let b = 3; let result = a * b; console.log(result); // Output: 6
4. Division Operator (/):
The division operator is represented by the symbol "/". It is used to divide one value by another.
Example:
let a = 10; let b = 2; let result = a / b; console.log(result); // Output: 5
5. Modulus Operator (%):
The modulus operator is represented by the symbol "%". It returns the remainder of a division operation.
Example:
let a = 10; let b = 3; let result = a % b; console.log(result); // Output: 1
6. Increment Operator (++) and Decrement Operator (–):
The increment operator "++" is used to increase the value of a variable by 1. The decrement operator "–" is used to decrease the value of a variable by 1.
Example:
let a = 5; a++; // Increment operator console.log(a); // Output: 6 let b = 10; b--; // Decrement operator console.log(b); // Output: 9
7. Exponentiation Operator (**):
The exponentiation operator is represented by the symbol "**". It raises the first operand to the power of the second operand.
Example:
let a = 2; let b = 3; let result = a ** b; console.log(result); // Output: 8
These are the basic mathematical operators available in JavaScript. They allow you to perform various mathematical calculations and operations on variables, which are fundamental in JavaScript programming.
Other recent questions and answers regarding Examination review:
- Why is it important to avoid using keywords as variable names in JavaScript?
- What are the special characters allowed in variable names in JavaScript?
- What happens if you declare a variable with the same name but different casing in JavaScript?
- What are the naming conventions to follow when declaring variables in JavaScript?

